Proposal: Promise.prototype.Finally

Domenic Denicola domenic at domenicdenicola.com
Mon Aug 18 16:22:05 PDT 2014


> Is the consensus that this won't make it into Promise until at least ES7, and then only if there's enough of a call for it?

Although I find the arbitrary division of features into "ES6" and "ES7" distasteful personally: yes, ES6 will not be adding new APIs. That doesn't mean that Promise.prototype.finally won't ship in all major browsers before other ES6 features do. But it does mean that we won't be submitting a document to the Ecma general assembly with Promise.prototype.finally before we submit one with proper tail calls.

> To be honest, if ES7 has something like async/await then it won't need Promise.prototype.finally.

That's mostly true, I suppose, but it can increase brevity in some cases:

```js
function doThingySafely() {
  return doThingy().finally(cleanup);
}

// vs.

async function doThingySafely() {
  try {
    return await doThingy();
  } finally {
    return cleanup();
  }
}
```


More information about the es-discuss mailing list