We have a pretty big code base that made use of RSVP which we are moving to node 4.3.2+. The only RSVP feature we use frequently that's not in the native js Promise api is the hash() function. I expected to either use the RSVP source or find something on stack overflow. Most people appear to be be solving the problem with different constraints & requirements which makes existing solutions I found somewhat complex so I whipped up my own:
function hash (hashOfPromises) {
var keys = Object.keys(hashOfPromises);
return Promise.all(keys.map(function (key) {
return hashOfPromises[key];
})).then(function (list) {
return list.reduce(function (hashOfResolved, value, i) {
hashOfResolved[keys[i]] = value;
return hashOfResolved;
}, {});
});
}