new-chain

Create chaining APIs from functions

npm install new-chain
8 downloads in the last day
45 downloads in the last week
295 downloads in the last month

new-chain

Create chaining APIs from functions

Install

$ npm install new-chain

Usage

x = 0
val = newChain(mul, sum, sub) // or: { alias: mul, mul:mul } or: newChain({ alias: mul }, mul)

val.sum(8).sub(2).mul(3)

x
// => 18

function mul(n){
    x *= n
}

function sum(n){
    x += n
}

function sub(n){
    x -= n
}

from

x = [1, 2, 3]

val = newChain.from(x)(foo, bar)

val
// => [1, 2, 3]

val.foo().bar()
// => [1, 2, 3]

npm loves you