tildeio/rsvp.js — pull request #113 by decasia (2013-09-17 15:13:06+00:00)
Title: Add allSettled to RSVP

The existing `RSVP.all` method implements essentially a fail-fast method of resolving an array of promises. But sometimes you don't want the fail-fast behavior and instead want to be able to inspect the final states of a bunch of promises, whether they succeed or fail. One use case I've encountered is in doing validation handling when saving a bunch of related records in Ember — if you want to be able to trigger client-side logic based on the responses to *all* the record states, `RSVP.all` is not really effective, because it doesn't continue after the first one.

So this PR would add another method `RSVP.allSettled` that transforms an array of promises into a promise for an array of their states. These states will take one of the following formats:

```
{ state: 'fulfilled', value: value }
or
{ state: 'rejected', reason: reason }
```

These result states are taken from [a similar allSettled function in the Q library](https://github.com/kriskowal/q/blob/master/q.js#L1585) (compare also the [allSettled tests](https://github.com/kriskowal/q/blob/master/spec/q-spec.js#L1175)). And for coherence with the existing RSVP codebase, I've kept the implementation, function and variable names, etc, as close as possible to `RSVP.all` for the time being.

I've never sent a GitHub PR before, so I'd obviously be grateful for any tips or suggestions!