onex-utils
onex-utils copied to clipboard
添加条件判断装饰器
函数描述
通过装饰器针对参数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情况