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

Function pool

docs/scripts/gen-paicoding-canonical.mjs:54–66  ·  view source on GitHub ↗
(items, worker, size)

Source from the content-addressed store, hash-verified

52}
53
54async function pool(items, worker, size) {
55 const results = new Array(items.length);
56 let i = 0;
57 await Promise.all(
58 Array.from({ length: Math.min(size, items.length) }, async () => {
59 while (i < items.length) {
60 const idx = i++;
61 results[idx] = await worker(items[idx]);
62 }
63 })
64 );
65 return results;
66}
67
68const slugs = [
69 ...new Set(

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected