Pool
like Promise.all but you can limit the concurrency
Install / Use
/learn @ricokahler/PoolREADME
@ricokahler/pool ·

Pool is like Promise.all but you can specify how many concurrent tasks you want at once.
Well tested. | Zero dependencies and small size.
npm i @ricokahler/pool
import pool from '@ricokahler/pool';
async function blah() {
const texts = await pool({
collection: [1, 2, 3, 4, 5],
maxConcurrency: 2, // only fetch two pages at a time
task: async (n) => {
const response = await fetch(`/go/download/something/${n}`);
const text = await response.text();
return text;
},
});
console.log(texts); // an array of the 5 items downloaded
}
maxConcurrency is optional. If omitted it will default to just using Promise.all with no max concurrency.
Related Skills
node-connect
340.2kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
84.1kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
340.2kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
84.1kCommit, push, and open a PR
