Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Async Function Composition.
JavaScript
branch: master

0.0.4

latest commit 2ffac8de6c
@azer authored

README.md

comp

Async function composition. Similar to promises.

$ npm install comp

Need more features? See andthen

Usage

steps = comp(step1, step2, step3)

steps(value1, function(error, value4){

    if(error) throw error

    value4
    // => what step3 returns. see below.

})

function step1(value1, callback){}
function step2(value2, callback){}
function step3(value3, callback){}

You can add functions to the composition later;

steps = comp(step1).then(step2).then(step3)

First step may not get any initial value:

steps = comp(step0, step1, step2, step3)

steps(function(error, value4){

    if(error) throw error

    value4
    // => what step3 returns. see below.

})

function step0(callback){

    callback(null, value1)

}

Something went wrong with that request. Please try again.