This package has been deprecated

Author message:

Development of this module has been stopped.

promise-infinite

0.0.9 • Public • Published

promise infinite

NPM version Build status License Code style

alternative Promise.all for handling very many promises

Installation

$ npm install --save promise-infinite

...or:

$ yarn add promise-infinite

Motivation

This module is for when you need to throw hundreds or even thousands of Promises at a problem. Say you are doing lots of small HTTP requests or stating thousands of files on the filesystem, instead of doing async work in a serial manner just Array.prototype.map an array of URLs or filenames to a Promise interface (or create a wrapper) for the IO work you need to do and then promiseInfinite(yourArrayOfPromises) and it will just handle it.

If you use Promise.all on a lot of requests it will just choke, whether the JavaScript runtime or the OS because of too much IO in one go, this module just breaks down the work into more manageable chunks, plus if there are any Promise rejections it will still continue with the work load and return a list of rejections at the end.

Usage

const promiseInfinite = require('promise-infinite')
 
const ops = [
  new Promise(resolve => {
    // async work
    resolve()
  }),
 
  // hundreds or thousands of promises
]
 
promiseInfinite(ops)
  .then(results => {
    // results is an array containing the output
    // of each promise that resolved successfully
 
    // there is also a `.rejected` property with
    // an array of promises that were rejected
    // these could then be tried again for example
  })

Readme

Keywords

none

Package Sidebar

Install

npm i promise-infinite

Weekly Downloads

0

Version

0.0.9

License

MIT

Last publish

Collaborators

  • roryrjb