Skip to content

Instantly share code, notes, and snippets.

@iohcidnal
Created July 5, 2018 02:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iohcidnal/c302b9f3c542a6c7e408296ea79cbaf0 to your computer and use it in GitHub Desktop.
Save iohcidnal/c302b9f3c542a6c7e408296ea79cbaf0 to your computer and use it in GitHub Desktop.
Concurrently dispatches promises
(async () => {
const promises = [
new Promise(resolve => resolve(1)),
new Promise(resolve => resolve(2)),
new Promise(resolve => resolve(3)),
new Promise(resolve => resolve(4)),
new Promise(resolve => resolve(5)),
];
const [...result ] = await Promise.all(promises.map(async p => {
const result = await p;
return result;
}));
console.log(result);
}
)();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment