A simple function for allowing partial function application in JavaScript.
function foo(a, b, c) {
return [a, b, c]
}
var bar = foo.curry(1, 2)
bar(3) // => [1, 2, 3]
Even if enough arguments are provided, the underlying function is not evaluated until the returned function is evaluated.
var baz = foo.curry(1, 2, 3)
baz() // => [1, 2, 3]
this
will be bound when the underlying function is evaluated.
function what_is_this() {
return "This is " + this + "!"
}
var fn = what_is_this.curry()
fn.call("Sparta") // => "This is Sparta!"