Created
March 30, 2020 17:14
-
-
Save Stradivario/42e56fcac94837de3fcd64746d096027 to your computer and use it in GitHub Desktop.
reader.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// export function Reader<T>(...arg: ObjectType<T>[]): MethodDecorator { | |
// return ( | |
// target: object, | |
// propertyKey: string | symbol, | |
// descriptor: TypedPropertyDescriptor<any> | |
// ) => { | |
// const method = descriptor.value; | |
// descriptor.value = function(args: unknown[]) { | |
// args = args || []; | |
// const requiredParameters = | |
// (Reflect.getOwnMetadata( | |
// metadataSymbol, | |
// target, | |
// propertyKey | |
// ) as MetadataParams[]) || []; | |
// requiredParameters.push( | |
// ...arg.map((handler, index) => ({ handler, index })) | |
// ); | |
// requiredParameters.forEach( | |
// param => (args[param.index] = set(param.handler)) | |
// ); | |
// return method.apply(this, args); | |
// }; | |
// }; | |
// } | |
// export function Injector<T>(handler: ObjectType<T>): ParameterDecorator { | |
// return (target: object, propertyKey: string | symbol, index: number) => { | |
// const params = | |
// (Reflect.getOwnMetadata(metadataSymbol, target, propertyKey) as Array< | |
// MetadataParams | |
// >) || []; | |
// params.push({ index, handler }); | |
// Reflect.defineMetadata(metadataSymbol, params, target, propertyKey); | |
// }; | |
// } | |
// function Compact<T extends new (...args: any[]) => {}>(constructor: T) { | |
// console.log('-- decorator function invoked --'); | |
// return class extends constructor { | |
// gears = 5; | |
// wheels = 3; | |
// }; | |
// } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment