Last active
November 26, 2017 06:22
-
-
Save jfairbank/b356f676a7956ea0ed95 to your computer and use it in GitHub Desktop.
JS Wrap
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
function wrap(orig, newDef) { | |
return function(...args) { | |
return newDef.apply(this, [orig].concat(args)); | |
}; | |
} | |
myLib.getTotal = wrap(myLib.getTotal, function(orig, ...args) { | |
let total = orig.apply(this, args) * 0.8; | |
return total + this.getTax(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment