()
| 178 | let next = 0 |
| 179 | |
| 180 | async function run(): Promise<void> { |
| 181 | while (next < items.length) { |
| 182 | const current = next++ |
| 183 | results[current] = await worker(items[current], current) |
| 184 | } |
| 185 | } |
| 186 | |
| 187 | const runners = Array.from({ length: Math.min(limit, items.length) }, run) |
| 188 | await Promise.all(runners) |