Created
August 6, 2013 07:28
-
-
Save ducin/6162784 to your computer and use it in GitHub Desktop.
currying is a mechanism to pre-fill arguments of a later function call
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
if (!Function.prototype.curry) { | |
(function () { | |
var slice = Array.prototype.slice; | |
Function.prototype.curry = function () { | |
var target = this; | |
var args = slice.call(arguments); | |
return function () { | |
var allArgs = args; | |
if (arguments.length > 0) { | |
allArgs = args.concat(slice.call(arguments)); | |
} | |
return target.apply(this, allArgs); | |
}; | |
}; | |
}()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment