Created
August 26, 2011 22:52
-
-
Save edfuh/1174626 to your computer and use it in GitHub Desktop.
curry
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
//extend native. bad? | |
Function.prototype.curry = function () { | |
var aslice = [].slice, _method = this, args = aslice.call(arguments); | |
if (!args.length) return _method; | |
return function () { | |
var a = args.concat(aslice.call(arguments)); | |
return _method.apply(this, a); | |
} | |
} | |
//as function. better | |
curry = function (func, args) { | |
var aslice = [].slice, _method = func, args = aslice.call(arguments, 1); | |
if (!args.length) return _method; | |
return function () { | |
var a = args.concat(aslice.call(arguments)); | |
return _method.apply(this, a); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment