Skip to content

Instantly share code, notes, and snippets.

@SebastianHGonzalez
Created January 2, 2019 18:33
Show Gist options
  • Select an option

  • Save SebastianHGonzalez/aeecca7394d80f2c79803f2aaf74ab90 to your computer and use it in GitHub Desktop.

Select an option

Save SebastianHGonzalez/aeecca7394d80f2c79803f2aaf74ab90 to your computer and use it in GitHub Desktop.
function timeAspect(joinPoint, logger) {
const aspect = {
logger,
timer: {
start: function () { this.startTime = Date.now() },
stop: function () { this.stopTime = Date.now() },
time: function () { return this.stopTime - this.startTime }
},
before: function () { this.timer.start() },
after: function () { this.timer.stop(), this.logger.log(timer.time) }
};
return decorate(joinPoint, aspect)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment