Skip to content

Instantly share code, notes, and snippets.

@SebastianHGonzalez
Last active January 1, 2019 17:11
Show Gist options
  • Save SebastianHGonzalez/2cba6ebaa61385f05a4834f18102b973 to your computer and use it in GitHub Desktop.
Save SebastianHGonzalez/2cba6ebaa61385f05a4834f18102b973 to your computer and use it in GitHub Desktop.
My first try at AOP
function loggerAspect(joinPoint, logger) {
return (...args) => {
logger.log("logging");
return joinPoint(...args);
}
}
function add(a, b) {
return a + b;
}
add(1, 2);
// <- 3
add = loggerAspect(add, console);
add(1, 2);
// logging
// <- 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment