Created
November 21, 2015 19:00
-
-
Save kylewelsby/1f973ea92c745dddc7c4 to your computer and use it in GitHub Desktop.
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
function promiseHash (hash) { | |
var promises = [] | |
Object.keys(hash).map(function (key, index) { | |
return promises[index] = hash[key] | |
}) | |
return Promise.all(promises).then(function (resolved) { | |
var response = {} | |
Object.keys(hash).map(function (key, index) { | |
response[key] = resolved[index] | |
}) | |
return response | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment