JavaScript interview: Run async tasks with a concurrency limit
hard
promises
async
concurrency
Write mapLimit(items, limit, fn). fn(item) returns a promise. Run at most limit calls at once, start the next one as soon as a slot frees up, and resolve to the results in input order.
If any call rejects, reject with that error.
Your code
Runs in a Web Worker in your browser. Tests use real timers, so a run takes a second or two.