Proposal for Promise.prototype.flatten

Aaron Silvas aaronsilvas at
Tue Apr 23 20:24:52 UTC 2019

Looking for interest, and TC39 champion.

The basic idea is to provide a simpler, more consistent interface, and
easier to read code over using try/catches for async code paths. Regardless
of which errors are handled or ignored, it's treated as nothing more than
another input in the result, not all that dissimilar to callbacks.

async function test(promise1, promise2, promise3) {
  const [, val1] = await promise1.flatten(); // ignore exceptions
  const [err, [val2, val3] = []] = await Promise.all([promise2,

  if (err) throw err; // throw to caller

  return val1 + val2 + val3;

Original topic that spurred interest in this pattern:

Spec discussions:


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list