Skip to content

Instantly share code, notes, and snippets.

@cesalberca
Created April 14, 2020 18:56
Show Gist options
  • Save cesalberca/103985b8c7b34fcade7df245086ae387 to your computer and use it in GitHub Desktop.
Save cesalberca/103985b8c7b34fcade7df245086ae387 to your computer and use it in GitHub Desktop.
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