sindresorhus / p-map

Map over promises concurrently
MIT License
1.29k stars 58 forks source link

Decimal values for concurrency #26

Closed Gabisampaio closed 4 years ago

Gabisampaio commented 4 years ago

The following loop controls the number of pending promises returned by mapper.

for (let i = 0; i < concurrency; i++) { next(); if (isIterableDone) { break; } }.

However, if concurrency has a decimal value (for instance, if concurrency = 2.5), there will be 3 pending promises because the loop allows one more iteration to happen (the case in which i=2).

Is this a bug or it is actually intentional? Shouldn't we avoid such cases? If so, the bug could potentially be fixed by adding a condition when validating the value of concurrency.