MCPcopy Create free account
hub / github.com/arctic-cli/interface / work

Function work

packages/arctic/src/util/queue.ts:21–32  ·  view source on GitHub ↗
(concurrency: number, items: T[], fn: (item: T) => Promise<void>)

Source from the content-addressed store, hash-verified

19}
20
21export async function work<T>(concurrency: number, items: T[], fn: (item: T) => Promise<void>) {
22 const pending = [...items]
23 await Promise.all(
24 Array.from({ length: concurrency }, async () => {
25 while (true) {
26 const item = pending.pop()
27 if (item === undefined) return
28 await fn(item)
29 }
30 }),
31 )
32}

Callers 1

migrateFromGlobalFunction · 0.90

Calls 1

fnFunction · 0.70

Tested by

no test coverage detected