1.0.3 • Published 7 years ago

better-promise-hash v1.0.3

Weekly downloads
3
License
MIT
Repository
-
Last release
7 years ago

better-promise-hash travis status

A better implementation of a hash function for Promise. Returns a promise that is fulfilled when all the given promises have been fulfilled. Any rejection rejects the whole hash.

The object passed to hash will be returned with promises replaced with the promise result. Any non-promise objects will simply remain in the result.

Sometimes you feel like a nut, sometimes you don't

This modules adds a hash function to Promise. This allows you to do things like this:

let object= {
  one: new Promise((resolve,reject) => {
      resolve('somePromiseValue');
    }),
  two: 'someOtherValue'
};

Promise.hash(object).then((result) => {
  console.log(result.one); // echos "somePromiseValue"
  console.log(result.two); // echos "someOtherValue"
});

This is similar to RSVP.hash, which supports a mix of promises and non-promise objects.

Hope that helps!

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago