Skip to content
Create chaining APIs from functions
JavaScript
Latest commit 3267917 Jul 23, 2013 @azer Update README.md
Failed to load latest commit information.
.gitignore first commit Apr 23, 2013
.npmignore first commit Apr 23, 2013
.travis.yml Create .travis.yml May 14, 2013
README.md Update README.md Jul 23, 2013
index.js from Jun 16, 2013
package.json 0.0.1 Jun 16, 2013
test.js from Jun 16, 2013

README.md

new-chain Build Status

Create chaining APIs from functions

Install

$ npm install new-chain

Usage

Num(3).sum(10).sub(5).mul(2).val()
// => 16

function Num(x){

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

    chain.val = val

    return chain

    function mul(n){
        x *= n
    }

    function sum(n){
        x += n
    }

    function sub(n){
        x -= n
    }

    function val(n){
        return x
    }

}

from

x = [1, 2, 3]

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

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

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

Something went wrong with that request. Please try again.