Created
June 9, 2014 21:55
-
-
Save rickcnagy/d9ea99c33cbc8b548f31 to your computer and use it in GitHub Desktop.
Extend an existing function. Great for writing code on top of existing systems.
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 extend(oldFunc, newFunc, callAfter) { | |
callAfter = callAfter || true; | |
if (callAfter) { | |
return function() { | |
var ret = oldFunc.apply(this, arguments); | |
newFunc.apply(this, arguments); | |
return ret; | |
} | |
} else { | |
return function() { | |
newFunc.apply(this, arguments); | |
return oldFunc.apply(this, arguments); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment