Skip to content

Instantly share code, notes, and snippets.

@Janoyan
Created April 5, 2020 10:56
Show Gist options
  • Save Janoyan/f5101468c45d2d55c4f1cca8e9bc9801 to your computer and use it in GitHub Desktop.
Save Janoyan/f5101468c45d2d55c4f1cca8e9bc9801 to your computer and use it in GitHub Desktop.
const bluebird = require('bluebird');
async function task(data, ms = 500) {
console.log(data);
await bluebird.delay(ms);
return data;
}
bluebird.map(['A', 'B', 'C', 'D', 'E', 'F'], async (item) => {
return task(item);
}, { concurrency: 3 }).then((result) => {
console.log(result);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment