Last active
May 3, 2017 06:55
-
-
Save sebringj/454cadc7773d5fcd13eaa740b077e63f to your computer and use it in GitHub Desktop.
maps Promise.all
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 function promiseMapAll(promiseMap) { | |
const keys = Object.keys(promiseMap); | |
const promises = keys.map(key => promiseMap[key]); | |
const promisesArr = await Promise.all(promises); | |
let objMapped = {}; | |
keys.forEach((key, i) => { | |
objMapped[key] = promisesArr[i]; | |
}); | |
return objMapped; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Why not use
Object.values()
? As far as a name goes,promiseMapAll
is not horrible, but how aboutpromiseAllObject
?