Skip to content

Instantly share code, notes, and snippets.

@denismaster
Last active March 12, 2017 17:18
Show Gist options
  • Save denismaster/b04f5bf3368e54a49747412ddd193a77 to your computer and use it in GitHub Desktop.
Save denismaster/b04f5bf3368e54a49747412ddd193a77 to your computer and use it in GitHub Desktop.
TypeScript runtime function decorator.
export class DecoratorFactory {
public createWithCallback(func: Function, callback: any) {
if (!callback || typeof (callback) !== "function")
return undefined;
return function () {
const result = func.apply(this, arguments); // (*)
callback();
return result;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment