MCPcopy Create free account
hub / github.com/anomalyco/console / queue

Function queue

packages/core/src/util/queue.ts:1–20  ·  view source on GitHub ↗
(
  concurrency: number,
  items: T[],
  processItem: (item: T) => Promise<R>
)

Source from the content-addressed store, hash-verified

1export async function queue<T, R>(
2 concurrency: number,
3 items: T[],
4 processItem: (item: T) => Promise<R>
5) {
6 const workers = [...new Array(concurrency)];
7 await Promise.all(
8 workers.map(async (_, index) => {
9 let count = 0;
10 while (true) {
11 const item = items.pop();
12 if (!item) {
13 break;
14 }
15 await processItem(item);
16 count++;
17 }
18 })
19 );
20}

Callers 6

handlerFunction · 0.90
index.tsFile · 0.90
index.tsFile · 0.90
sync-stages.tsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected