comp

Async Function Composition

Async function composition. Similar to promises.

$ npm install comp

Need more features? See andthen

steps = comp(step1, step2, step3)
 
steps(value1, function(errorvalue4){
 
    if(error) throw error
 
    value4
    // => what step3 returns. see below. 
 
})
 
function step1(value1callback){}
function step2(value2callback){}
function step3(value3callback){}

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(errorvalue4){
 
    if(error) throw error
 
    value4
    // => what step3 returns. see below. 
 
})
 
function step0(callback){
 
    callback(null, value1)
 
}