Skip to content

KoryNunn/shuv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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');

About

Partial application. Shuv args around the place.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published