Skip to content

Instantly share code, notes, and snippets.

@Stradivario
Created March 30, 2020 17:14
Show Gist options
  • Save Stradivario/42e56fcac94837de3fcd64746d096027 to your computer and use it in GitHub Desktop.
Save Stradivario/42e56fcac94837de3fcd64746d096027 to your computer and use it in GitHub Desktop.
reader.ts
// 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