New Promise Syntax Proposal

Pranay Prakash pranay.gp at gmail.com
Mon Nov 6 19:20:54 UTC 2017


Lot of good ideas mentioned in this thread, and I think in general, the
async/await pattern helps to make code like this more terse.

Rather than inventing new syntax like:

```
promise promiseFunction(resolve, reject, …args) {  // call to reject() or
resolve()
}
…

the existing way of implementing this is:

```
async function promiseFunction(…args) {  // return something (to resolve) or
throw an error (to reject)
}
…
We already have the latter, and it is cleaner IMO
Cheers,Pranay  





On Mon, Nov 6, 2017 1:05 PM, Augusto Moura augusto.borgesm at gmail.com  wrote:
Using arrow functions it doesn't seems so verbose
```js
function requestInput(question) {  return new Promise(function(resolve) {   
interface.question(question, function(input) {      resolve(input);    })  })}
```can be written as:
```js
const requestInput = question => new Promise((resolve) => {
interface.question(question, resolve); // You can wrap resolve in a `unary`
helper if more than 1 argument is problematic
});
```

I don't see a problem with verbosity-- 
Augusto Moura
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20171106/7af61fb3/attachment-0001.html>


More information about the es-discuss mailing list