Nocturnally Psychologizing Millipede

    promise-rockfall

    1.0.2 • Public • Published

    promise-rockfall

    master branch build status dependencies version status

    NPM

    desscription

    Runs an array of promises in chunked series one after another.

    installation

    npm i -S promise-rockfall

    usage

    const rockfall = require('promise-rockfall');
    // Array of promises
    const promises = Array(100).fill(null).map(() => (Promise.resolve(Math.random())));
    // Process promises in several batches of 10 promises at max.
    rockfall(promises, 10);
    // It is possible do something when each batch is resolved
    rockfall(promises, 10, (rs) => {console.log(rs);});
    // It is possible to do something when everything is resovled
    rockfall(promises, 10)
      .then(() => {console.log('all done');})
      .catch((err) => {console.error(err);});

    API

    rockfall(functions, size, batchThen) -> promise

    Runs an array of promises in chunked series one after another.

    functions

    Required Type: array[function]

    size

    Optional Type: integer

    batches' size

    batchThen

    Optional Type: function

    function that takes the resolution of one batch of promises in input

    Keywords

    Install

    npm i promise-rockfall

    DownloadsWeekly Downloads

    4

    Version

    1.0.2

    License

    LGPL-3.0

    Last publish

    Collaborators

    • sstephant