Node Promiscuous Modules
npm’s 2019 JavaScript ecosystem survey analysis is now available!Get your copy here »

promise.extra

1.2.2 • Public • Published

Build Status

promise.extra

Promise.series and Promise.waterfall with vanilla es Promise/thenable

Install

$ npm install promise.extra --save

Usage

import {
  series,
  waterfall
} from 'promise.extra'
 
// Unlike `Promise.all`, `series` receives an array of factory functions instead of `Promise`'s.
series([f1, f2, f3]).then(values => {
  console.log(values)
})
 
waterfall([f1, f2, f3], initValue).then(result => {
  console.log(result)
})

series(tasks, [...args])

  • tasks Array.<PromiseFactory> an array of functions each of which returns a Promise
  • PromiseFactory function() : Promise a factory function which returns a Promise
  • args extra arguments be passed into each PromiseFactory

Returns Promise

waterfall(tasks [, initValue] [, ...args])

  • tasks Array.<PromiseFactory>
  • PromiseFactory function(x) : Promise a factory function which receives a parameter and returns a Promise
  • initValue any= optional initial value which will be passed into the first factory function.
  • args extra arguments be passed into each PromiseFactory

Returns a Promise.

License

MIT

Install

npm i promise.extra

DownloadsWeekly Downloads

131

Version

1.2.2

License

MIT

Last publish

Collaborators

  • avatar