Yes, it would have been clever of me to predict the semantics 3 years
ago. ;-)
But as I mention in the stackoverflow post, depending on context and the
type(s) of values expected, errors can often be distinguished easily
enough in practice, if not in general.
That said, I've never actually had an opportunity to use this pattern
for anything...
.: Jan-Ivar :.
On 10/30/19 6:39 PM, Boris Zbarsky wrote:
On 10/30/19 6:19 PM, Jan-Ivar Bruaroey wrote:
This always seemed trivial to me to do with:
Promise.all(promises.map(p => p.catch(e => e)))
This has different semantics from Promise.allSettled, right? In
particular, it effectively treats rejected promises as resolved with the
rejection value, forgetting the fact that they were rejected.
Promise.allSettled, on the other hand, preserves information about the
state.
I think you can still polyfill it, using something like:
Promise.all(promises.map(p => p.then(
v => { { status: "fulfilled", value: v } },
e => { { status: "rejected", reason: e } }));
though I think this might create more temporary Promises than allSettled
does...
-Boris
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform