()
| 48 | if (total > 0 && concurrency <= 0) throw new RangeError('concurrency must be positive'); |
| 49 | let next = 0; |
| 50 | const addAnother = () => promiseCreator(next++).finally(() => { |
| 51 | if (next < total) return addAnother(); |
| 52 | }); |
| 53 | const promises = []; |
| 54 | for (let i = 0; i < concurrency && i < total; i++) { |
| 55 | promises.push(addAnother()); |