Last active
February 19, 2016 06:45
-
-
Save carlosascari/78c9eb997a1583df93d3 to your computer and use it in GitHub Desktop.
A Hacky way of renaming an existing function
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
/** | |
* Renames and existing function. | |
* | |
* @private | |
* @method rename_function | |
* @param name {String} | |
* @param fn {Function} | |
* @return Function | |
*/ | |
function rename_function(name, fn) | |
{ | |
return ( | |
new Function( | |
"return function (call) { return function " + | |
name + | |
" () { return call(this, arguments) }; };" | |
)())(Function.apply.bind(fn) | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment