0.2.1 • Published 7 years ago

waterfally v0.2.1

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

Waterfally

Waterfally do similar as async.waterfall (sequential flow control) with support of promises.

Since Promise.all(promiseArr) || Promise.spread(promiseArr) execs promises simultaneously, each of the functions in the promiseArr cannot depend on another, and if you want promises execute in order or some of the promises need the resolved value of another, this library is for you.

Installation

npm install waterfally

Usage

var waterfall = require("waterfally");
var func1 = function(){
        // return a promise
    },
    func2 = function(res1){
        // optionally use res1 
        // which is resolved from func1 
        // and return a promise
    },
    func3 = function(res2){
        // like func2
    },
    promiseSequence = [func1, func2, func3];
    
waterfall(promiseSequence) 
    // the promiseSequence will executes sequentially
    // just like func1().then(func2).then(func3)
    .then(function(res){
        // use res
    })
    .catch(function(err){
        // deal with error
    });
0.2.1

7 years ago

0.2.0

7 years ago

0.1.0

9 years ago