Created
March 22, 2012 20:02
-
-
Save arian/2163009 to your computer and use it in GitHub Desktop.
Parentify primes
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
var parentify = function(prime){ | |
var parent = prime.parent | |
if (!parent) throw new Error('Cannot parentify this prime') | |
var method = prime.prototype.parent = function(name){ | |
var fn = parent[name] | |
if (typeof fn != 'function') throw new Error('This method called with parent() does not exist') | |
delete this.parent | |
var ret = fn.apply(this, array.slice(arguments, 1)) | |
this.parent = method | |
return ret | |
} | |
if (parent.constructor.parent) parentify(parent.constructor) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment