Async Task Pool — Concurrent Promise Execution with Rate Limiting (mapLimit)

Implement an async mapLimit(array, limit, asyncTransformFn) function that works like Promise.all() but with a strict concurrency cap. Given an input array, an async transform function, and a max-concurrency integer, it should process all items and return their results in original order — but never run more than 'limit' async operations simultaneously. As soon as one slot frees up (a promise resolves), the next pending item should immediately start. Handle rejections (fail-fast vs collect-all modes), empty arrays, and a limit of Infinity (equivalent to Promise.all). This is the backbone of real-world HTTP request batching and task schedulers.

Examples
Input: []
Output:
Hints

Async Task Pool — Concurrent Promise Execution with Rate Limiting (mapLimit)

Implement an async mapLimit(array, limit, asyncTransformFn) function that works like Promise.all() but with a strict concurrency cap. Given an input array, an async transform function, and a max-concurrency integer, it should process all items and return their results in original order — but never run more than 'limit' async operations simultaneously. As soon as one slot frees up (a promise resolves), the next pending item should immediately start. Handle rejections (fail-fast vs collect-all modes), empty arrays, and a limit of Infinity (equivalent to Promise.all). This is the backbone of real-world HTTP request batching and task schedulers.