Returns a wrapper that runs at most concurrency async tasks at a time.
concurrency
Tasks queue up beyond the limit. The wrapper returns the same value/rejection the underlying task does, so it composes naturally with Promise.all.
Promise.all
const limit = pLimit(2)await Promise.all(urls.map(u => limit(() => fetch(u)))) Copy
const limit = pLimit(2)await Promise.all(urls.map(u => limit(() => fetch(u))))
Returns a wrapper that runs at most
concurrencyasync tasks at a time.Tasks queue up beyond the limit. The wrapper returns the same value/rejection the underlying task does, so it composes naturally with
Promise.all.