concurrency-promise-pool
v1.0.1
Published
Type-safe async execution pool with dynamic concurrency limits and progress events.
Maintainers
Readme
concurrency-promise-pool
Why use concurrency-promise-pool? Processing hundreds of async calls using
Promise.allis a recipe for memory crashes, database connection exhausts, or hitting server 429 rate limit triggers.
A concurrency-limited promise pool executor. It queues tasks and executes them with a strict limit on maximum parallel executions, returning results dynamically.
⚡ Features
- Strict concurrency limit controls
- Accepts array of promise-returning functions
- Type-safe return array mapped to task order
- Performance-optimized queue scheduler
📦 Installation
npm i concurrency-promise-pool🚀 Usage
import { promisePool } from 'concurrency-promise-pool';
const urls = ['url1', 'url2', 'url3', 'url4'];
const fetchTask = (url) => async () => {
const res = await fetch(url);
return res.json();
};
const tasks = urls.map(fetchTask);
const results = await promisePool(tasks, { concurrency: 2 }); // Run max 2 in parallel⚙️ API Reference
promisePool(tasks, options)
tasks:Array<() => Promise<T>>- Task array.options:{ concurrency: number }- Returns
Promise<T[]>matching task results.
📺 Demonstration

📄 License
MIT License.
