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

Function mapWithConcurrency

apps/sim/lib/pptx-renderer/parser/zip-parser.ts:51–69  ·  view source on GitHub ↗
(
  items: T[],
  concurrency: number,
  mapper: (item: T) => Promise<void>
)

Source from the content-addressed store, hash-verified

49}
50
51async function mapWithConcurrency<T>(
52 items: T[],
53 concurrency: number,
54 mapper: (item: T) => Promise<void>
55): Promise<void> {
56 if (items.length === 0) return
57 const workerCount = Math.min(concurrency, items.length)
58 let cursor = 0
59
60 const workers = Array.from({ length: workerCount }, async () => {
61 while (true) {
62 const index = cursor++
63 if (index >= items.length) return
64 await mapper(items[index])
65 }
66 })
67
68 await Promise.all(workers)
69}
70
71/**
72 * Parse a .pptx file buffer and extract all relevant files, categorized by type.

Callers 1

parseZipFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected