shuv
v1.1.0
Published
Partial application. Shuv args around the place.
Downloads
1,577
Readme
Shuv
Partial application. Shuv args around the place.
Usage
var shuv = require('shuv');
Partial application
function readFile(fileName, callback){
...
}
var readMyFile = shuv(readFile, 'myFile.txt');
readMyFile(callback);
Placeholder args
function something(a, b, c){
return [a,b,c].join();
}
var withPlaceholders = shuv(something, shuv._, 2);
var result = withPlaceholders(1, 3); // -> 1,2,3
transform args
function something(a){
return a;
}
var withTransforms = shuv(something, shuv._(x => x.a));
var result = withPlaceholders({a: 1}); // -> 1
ignore/undefindify args
function something(a){
return a;
}
var withTransforms = shuv(something, shuv._());
var result = withPlaceholders({a: 1}); // -> undefined
get key off args
function something(a){
return a;
}
var withTransforms = shuv(something, shuv._('a'));
var result = withPlaceholders({a: 1}); // -> 1
block extra args
function errbackFn(error, result){
...
}
var onlyHandlesErrors = shuv(errbackFn, shuv._, shuv.$);
onlyHandlesErrors('someError', 'someResult');