Last active
January 14, 2018 10:54
-
-
Save schahriar/07ab2a9a8eff711a611dfc7b0b46b7d0 to your computer and use it in GitHub Desktop.
Map parallel #async-await #medium
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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