Chickencurry
Add some chickencurry to your functions
Installation
npm install chickencurry
Usage
Basic usage
var curry = require('chickencurry');
function add(a, b) {
return a + b;
}
var add1 = curry(add, 1);
var add12 = curry(add, 1, 2);
add1(3);
add12();
Recurry
You can curry a function and define the arguments for the curryied functions later.
function add(a, b) {
return a + b;
}
var curryiedAdd = curry(add);
var add1 = curryiedAdd(1);
var add2 = curryiedAdd(2);
add1(3);
add2(3);
Placeholder
You can curry a function using placeholders, if you want to set the i.e 3rd argument.
function join(a, b, sep) {
return a + sep + b;
};
var __ = curry.__;
var join_ = curry(join, __, __, '_');
join_('chicken', 'curry');
var joinCurry = curry(join);
var joinDash = joinCurry(__, __, '-');
joinDash('chicken', 'curry');
Function scope
If you want to curry a method of an object you have to bind the scope to the function.
var obj = {
name: 'stoeffel',
myFunc: function(arg) {
return arg + this.name;
}
};
var myFunc = curry(obj.myFunc.bind(obj), 'Hello ');
myFunc();