Create a pool of a specified concurrency that accepts functions that return promises
To use, just make a promise pool with the specified concurrency, then wrap the method in a
pool.open(() => /* the code that you want pooled */). The callback is necessary, as otherwise the code that you want pooled will execute before it is pooled. By pooling it, it executes once the pool entry is called.
const pool = 2 // 5 tasks at onceawait Promiseallpoolpoolpool
This package depends on
Promise.prototype.finally existing, which it does on Node v10 and above.
On older environments, you must use a shim, like so:
const pool =
npm install --save native-promise-pool
import pkg from ('native-promise-pool')
const pkg = require('native-promise-pool').default
This package is published with the following editions:
native-promise-pool/source/index.tsis TypeScript source code with Import for modules
native-promise-pool/edition-browsers/index.jsis TypeScript compiled against ES2019 for web browsers with Import for modules
native-promise-pool/edition-esnext/index.jsis TypeScript compiled against ESNext for Node.js 10 || 12 || 14 || 15 with Require for modules
native-promise-pool/edition-esnext-esm/index.jsis TypeScript compiled against ESNext for Node.js 12 || 14 || 15 with Import for modules
native-promise-pool/edition-deno/index.tsis TypeScript source code made to be compatible with Deno
These amazing people are maintaining this project:
No sponsors yet! Will you be the first?
These amazing people have contributed code to this project:
Unless stated otherwise all works are:
- Copyright © 2018+ Benjamin Lupton
and licensed under: