Skip to content

rajvantchahal/new-chain-notify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

new-chain-notify

Create chaining APIs from functions

Install

$ npm install new-chain-notify

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]

About

new chain notify

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published