-
-
Save awwright/4378445 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
// Would prefer to use an actual Function-subclass a lá `from`, so that I don't have to manually | |
// attach a .toString() to each instance; but this will do for the moment. | |
// FIXME: Will currently error out if you curry in more arguments than the function needs | |
define(Function.prototype, 'curry', function(){ | |
var self = this; | |
var result = new Function('bound', 'args', | |
"return this.apply(" | |
+" typeof bound === 'object' || typeof bound === 'function'? bound:this" | |
+" , curried.concat([].slice.call(args)) )" | |
); | |
result.toString = self.toString.bind(this); | |
result.final = this.final || this; | |
return result.bind(this, arguments); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment