q-hash
Is an implementation of RSVP hash for the Q library.
Last updated 5 years ago by porchdotcom .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install q-hash 
SYNC missed versions from official npm registry.

Q-Hash

Is an implementation of RSVP hash for the Q library.

Hash of promises

If you need to reference many promises at once (like all()), but would like to avoid encoding the actual promise order you can use hash(). If you pass an object literal (where the values are promises) to the hash() method it will return a new promise that will be fulfilled when all of the promises have been fulfilled; or rejected immediately if any promise is rejected.

The key difference to the all() function is that both the fulfillment value and the argument to the hash() function are object literals. This allows you to simply reference the results directly off the returned object without having to remember the initial order like you would with all().

var promises = {
  posts: getJSON("/posts.json"),
  users: getJSON("/users.json")
};

Qhash(promises).then(function(results) {
  console.log(results.users) // print the users.json results
  console.log(results.posts) // print the posts.json results
});

Current Tags

  • 1.1.1                                ...           latest (5 years ago)

4 Versions

  • 1.1.1                                ...           5 years ago
  • 1.1.0                                ...           5 years ago
  • 1.0.2                                ...           5 years ago
  • 1.0.1                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 1
Last Month 1
Dependencies (1)
  • q ^1.4.1
Dev Dependencies (8)

Copyright 2014 - 2016 © taobao.org |