Skip to content

Instantly share code, notes, and snippets.

@zbarnes757
Created January 14, 2019 19:00
Show Gist options
  • Save zbarnes757/eeaaecae4b3817750132af9ace1c5893 to your computer and use it in GitHub Desktop.
Save zbarnes757/eeaaecae4b3817750132af9ace1c5893 to your computer and use it in GitHub Desktop.
How to chunk Promises with Bluebird
const Promise = require('bluebird');
const stocks = ['aapl', 'googl', 'f', 'gm'];
function getThings(things) {
// DOCS: http://bluebirdjs.com/docs/api/promise.map.html
return Promise.map(things, thing => Promise.resolve(thing), { concurrency: 2 });
}
getThings(stocks);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment