Skip to content

Instantly share code, notes, and snippets.

@daronwolff
Created April 13, 2017 16:43
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 daronwolff/454449ec1756b44c8e363b60f3a63b93 to your computer and use it in GitHub Desktop.
Save daronwolff/454449ec1756b44c8e363b60f3a63b93 to your computer and use it in GitHub Desktop.
This function is similar to Promise.all but this receives an object. The param names from promisesObject is used to clasify the information
function resolveObject(promisesObject) {
const data = {};
let ready = Promise.resolve(null);
Object.keys(promisesObject).forEach((name) => {
const promise = promisesObject[name];
ready = ready.then(() => promise)
.then((value) => {
data[name] = value;
});
});
return ready.then(() => data);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment