In RSVP.js, there is a very elegant idiom:
var promises = [2, 3, 5, 7, 11, 13].map(function(id){
return getJSON("/post/" + id + ".json");
});
RSVP.all(promises).then(function(posts) {
// posts contains an array of results for the given promises
}).catch(function(reason){
// if any of the promises fails.
});
However I am using a library that already relies on, and exposes some of bluebird's api. So I'd rather avoid mixing in RSVP.js even if it may seem at times more elegant.
What would be the equivalent in bluebird, of the RSVP.js code snippet above?