Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Promise concurrency to nodejs #1707

Open
ramiloif opened this issue Nov 27, 2023 · 1 comment
Open

Promise concurrency to nodejs #1707

ramiloif opened this issue Nov 27, 2023 · 1 comment

Comments

@ramiloif
Copy link
Contributor

(This issue tracker is only for bug reports or feature requests, if this is neither, please choose appropriate channel from http://bluebirdjs.com/docs/support.html)

Please answer the questions the best you

If there is a feature that keeps you using bluebird. Please let us know so we can try and upstream it :)

There is a feature that keeps me using bluebird

In Promise.map there is a concurrency prop

Looking

@benjamingr
Copy link
Collaborator

You can use Node streams for that:

const { Readable } = require('stream');
const Promise = require('bluebird'); // to compare

async function fn(arg) {
  await Promise.resolve(); // simulate something async
  return arg;
}

Promise.map([1,2,3,4,5], fn, { concurrency: 3 }).then(results => console.log(results))

// streams

Readable.from([1,2,3,4,5]).map(fn, { concurrency: 3 }).forEach(result => console.log(result))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants