sindresorhus / p-limit

Run multiple promise-returning & async functions with limited concurrency
MIT License
1.84k stars 99 forks source link

What's the difference between your implementation and this KISS implementation? #68

Closed gquittet closed 1 year ago

gquittet commented 1 year ago

What's the difference between your implementation and this KISS implementation?

const allLimit = async (promises, { concurrency = 0 } = {}) => {
  if (concurrency < 1) {
    return (await Promise.all(promises.map((p) => p())));
  }
  let result = [];
  for (const promisesChunk of chunk(promises, concurrency)) {
    const t = await Promise.all(promisesChunk.map((p) => p()));
    result = result.concat(t);
  }
  return result;
};

Do we really need yocto-queue?

sindresorhus commented 1 year ago

Do we really need yocto-queue?

Yes: https://github.com/sindresorhus/p-limit/pull/46

gquittet commented 1 year ago

Thank you I haven't found this merge request before.

It's pretty clear to me.

I close this issue.