MCPcopy Index your code
hub / github.com/simstudioai/sim / worker

Function worker

apps/sim/lib/core/utils/concurrency.ts:22–28  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

20 let cursor = 0
21
22 const worker = async (): Promise<void> => {
23 while (true) {
24 const index = cursor++
25 if (index >= items.length) return
26 results[index] = await fn(items[index], index)
27 }
28 }
29
30 await Promise.all(Array.from({ length: workerCount }, worker))
31 return results

Callers 2

runWithConcurrencyFunction · 0.85
runFunction · 0.85

Calls 1

fnFunction · 0.50

Tested by

no test coverage detected