Created
April 14, 2020 18:56
-
-
Save cesalberca/103985b8c7b34fcade7df245086ae387 to your computer and use it in GitHub Desktop.
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 decorator @logged { | |
@wrap(f => { | |
const name = f.name; | |
function wrapped(...args) { | |
console.log(`starting ${name} with arguments ${args.join(", ")}`); | |
f.call(this, ...args); | |
console.log(`ending ${name}`); | |
} | |
Object.defineProperty(wrapped, "name", { | |
value: name, | |
configurable: true | |
}); | |
return wrapped; | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment