promise.waterfall2

1.0.0 • Public • Published

promise-waterfall2


NPM version Build Status

Runs an array of promises in series, each passing their results to the next promise in the array. support an initialization parameter

Install

$ npm install promise.waterfall2

Usage

var promiseWaterfall = require('promise.waterfall2')
 
function makeAdder (a) {
  return function (b) {
    b = b || 0
    return Promise.resolve(+ b)
  }
}
 
var addOne = makeAdder(1)
 
promiseWaterfall([
  addOne  // 1
  addOne, // 2
  addOne  // 3
])
.then(console.log)
.catch(console.error)
 
promiseWaterfall([
    addOne,
    addTwo
],5) // with initialization parameter
.then(console.log)
.catch(console.error)

API

promiseWaterfall(functions,[initialArgs]) -> promise

Runs the array of functions in series, waiting for each to resolve and passing each result to the next function in the array.

functions

Required Type: array[function]

Package Sidebar

Install

npm i promise.waterfall2

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

3.65 kB

Total Files

4

Last publish

Collaborators

  • x373241884y