Skip to content

Instantly share code, notes, and snippets.

@schahriar
Last active January 14, 2018 10:54
Show Gist options
  • Save schahriar/07ab2a9a8eff711a611dfc7b0b46b7d0 to your computer and use it in GitHub Desktop.
Save schahriar/07ab2a9a8eff711a611dfc7b0b46b7d0 to your computer and use it in GitHub Desktop.
Map parallel #async-await #medium
async (items) => {
// Note that async functions return a promise
const promises = items.map(async (item) => {
const result = await db.get(item);
// Log individual results as they finish
console.log(result);
return result;
});
const results = await Promise.all(promises);
console.log(results);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment