Created
October 10, 2014 09:36
-
-
Save kanghyojun/61b3c24bcf72702c6f80 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| Object.prototype.hijack = function(f) { | |
| var o = this; | |
| for(k in o) { | |
| (function(key) { | |
| if(o[key] instanceof Function) { | |
| var t = o[key].clone(); | |
| o[key] = function() { | |
| return f(o, key, t, arguments); | |
| } | |
| } | |
| })(k); | |
| } | |
| }; | |
| Function.prototype.clone = function() { | |
| var that = this; | |
| var temp = function temporary() { return that.apply(this, arguments); }; | |
| for(var key in this) { | |
| if (this.hasOwnProperty(key)) { | |
| temp[key] = this[key]; | |
| } | |
| } | |
| return temp; | |
| }; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment