onex-utils icon indicating copy to clipboard operation
onex-utils copied to clipboard

添加条件判断装饰器

Open Genluo opened this issue 2 years ago • 0 comments

函数描述

通过装饰器针对参数GET进行拦截,如果conditions返回为True,执行自定义operation函数

函数接口

type Options<I> = [conditions: (v: I) => boolean, operation: (target: Object, propertyKey: string | symbol) => void];

export interface handleDescriptor<T> {
  (target: Object, propertyKey: string | symbol, options: Options<T>): void;
}

测试用例

测试用例应该包含如下:T

  • [ ] 参数校验传入options非函数
  • [ ] conditions、operation执行过程中throw error
  • [ ] operation中参数是否正确
  • [ ] propertyKey为symbol情况

Genluo avatar Nov 17 '21 11:11 Genluo