Compare that to forEach, if one fails and you throw the rest don't get executed.
I suppose if whatever you're doing for each thing is async then they are equivalent equivalent but in general forEach has different sementics than Promise.all
Compare that to forEach, if one fails and you throw the rest don't get executed.
I suppose if whatever you're doing for each thing is async then they are equivalent equivalent but in general forEach has different sementics than Promise.all
In that "Promise protips" gist (https://gist.github.com/nolanlawson/6ce81186421d2fa109a4), I have an example of something closer to what you describe: the sequentialize() function will execute one promise after the other, and fail as soon as a single one fails.
However, if you need to actually run multiple promises in parallel, but cancel them as soon as a single one fails, then you might want something more advanced than promises, like RactiveJS (https://github.com/ractivejs/ractive) or RxJS (https://github.com/Reactive-Extensions/RxJS).
Also on your timing diagrams it may be worth indicating that methods don't start executing at the exact same time due to the single thread:
doSomething().then(function () { doSomethingElse(); }).then(finalHandler);
doSomething
|-----------------|
doSomethingElse(undefined)
..................|------------------| finalHandler(undefined)
....................|------------------|It's my understanding that the finally handler can not execute before the body of doSomethingElse has run. (Although I am unsure of a pretty/clear way to add this to a diagram ;) )
https://gist.github.com/dcherman/4dfba0d72c008ee5b59d
It's a reduce function, but it could work as a forEach as well.