MCPcopy Create free account
hub / github.com/itwanger/toBeBetterJavaer / runPool

Function runPool

scripts/convert-mdnice-images-to-cdn.js:345–355  ·  view source on GitHub ↗
(items, concurrency, worker)

Source from the content-addressed store, hash-verified

343}
344
345async function runPool(items, concurrency, worker) {
346 let cursor = 0;
347 const workers = Array.from({ length: Math.min(concurrency, items.length) }, async () => {
348 while (cursor < items.length) {
349 const index = cursor;
350 cursor += 1;
351 await worker(items[index], index);
352 }
353 });
354 await Promise.all(workers);
355}
356
357async function downloadImage(url) {
358 const response = await fetch(url, {

Callers 1

uploadAllFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected