Runs an array of promises in series, each passing their results to the next promise in the array.
Clone or download
notjrbauer Merge pull request #10 from xuxihai123/master
Support an initialization parameter
Latest commit 1a7197f Oct 26, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.editorconfig initial commit Dec 18, 2015
.gitattributes initial commit Dec 18, 2015
.gitignore Support an initialization parameter Jul 3, 2018
LICENSE initial commit Dec 18, 2015
README.md define addOne in example Jun 7, 2017
index.js Support an initialization parameter Jul 3, 2018
package.json 3.2.0 Jun 7, 2017
test.js Support an initialization parameter Jul 3, 2018

README.md

promise-waterfall

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

NPM

Install

$ npm install promise.waterfall --save

Usage

var promiseWaterfall = require('promise.waterfall')

function makeAdder (a) {
  return function (b) {
    b = b || 0
    return Promise.resolve(a + b)
  }
}

var addOne = makeAdder(1)

promiseWaterfall([
  addOne  // 1
  addOne, // 2
  addOne  // 3
])
.then(console.log)
.catch(console.error)

API

promiseWaterfall(functions) -> 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]