Skip to content

Instantly share code, notes, and snippets.

@jfairbank jfairbank/wrap.js
Last active Nov 26, 2017

What would you like to do?
JS Wrap
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
You can’t perform that action at this time.