MCPcopy
hub / github.com/Snailclimb/JavaGuide / mapConcurrent

Function mapConcurrent

scripts/docsearch-index.mjs:205–219  ·  view source on GitHub ↗
(items, worker, limit)

Source from the content-addressed store, hash-verified

203}
204
205async function mapConcurrent(items, worker, limit) {
206 const results = [];
207 let next = 0;
208
209 async function run() {
210 while (next < items.length) {
211 const current = next;
212 next += 1;
213 results[current] = await worker(items[current], current);
214 }
215 }
216
217 await Promise.all(Array.from({ length: Math.min(limit, items.length) }, run));
218 return results;
219}
220
221async function main() {
222 console.log(

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected