Created
November 29, 2014 21:20
-
-
Save zapthedingbat/1760ce9943a56462ef97 to your computer and use it in GitHub Desktop.
Remove a monkey-patch from a JavaScript method.
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
// Unpatch.js | |
// Sam Greenhalgh | |
// http://RadicalResearch.co.uk/ | |
// Example usage | |
// window.console.log = unpatch(window.console.log); | |
function unpatch(method) { | |
var _ = Function.prototype.apply; | |
var r; | |
Function.prototype.apply = function () { | |
r = this; | |
Function.prototype.apply = _; | |
}; | |
method(); | |
return r; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment