1.1.1 • Published 7 years ago

promise-chunkify v1.1.1

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

Chunkify

Run Promises with concurrency

Like Promise.all, but with concurrency.

Install

npm install --save promise-chunkify

Usage

import chunkify from "promise-chunkify";

(async () => {
    
    const results = await chunkify([
        () => returnsAPromiseWichResolvesTo(1),
        () => returnsAPromiseWichResolvedTo(2),
        () => returnsAPromiseWichResolvedTo(3)
    ], { concurrency: 1 });

    console.log(results); // [1, 2, 3]
})();

API

chunkify(factories, options)

NameTypeRequiredDescription
factoriesArraytrueArray of factory methods wich returns a promise
optionsObjectfalseChunkify options

Options

concurrency

Type: number

Define the concurrency chunk size, if not defined, 0 or negative value, all promises will be resolved at once so just use Promise.all([]) instead.

delayAfterEachChunk

Type: number

Optional timeout (in milliseconds) to delay between each promises chunk

License

This project is licensed under the MIT License - see the LICENSE file for details

1.1.1

7 years ago

1.1.0

7 years ago

1.0.0

7 years ago