dg-new-chain
Create chaining APIs from functions
Last updated 4 years ago by dguttman .
BSD · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install dg-new-chain 
SYNC missed versions from official npm registry.

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]

Current Tags

  • 0.0.1                                ...           latest (4 years ago)

1 Versions

  • 0.0.1                                ...           4 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (0)
None
Dev Dependencies (1)
Dependents (1)

Copyright 2014 - 2016 © taobao.org |