()
| 286 | let currentIndex = 0 |
| 287 | |
| 288 | async function worker(): Promise<void> { |
| 289 | while (currentIndex < items.length) { |
| 290 | const index = currentIndex++ |
| 291 | const item = items[index] |
| 292 | if (item !== undefined) { |
| 293 | results[index] = await fn(item, index) |
| 294 | } |
| 295 | } |
| 296 | } |
| 297 | |
| 298 | // Start workers up to the concurrency limit |
| 299 | const workers: Promise<void>[] = [] |