Use case: With promises, the expression body form of arrow functions is so
convenient. Alas, `throw` being a statement, you can’t use it there. For
example, the following code is not syntactically legal:
```js
asyncFunc()
.then(count = count = 0 ? count : throw new Error(...))
.then(...)
probably not exactly the fat arrow usage you were looking for ... but it
makes it trivial to inline any sort of block
```js
asyncFunc()
.then(count = count = 0 ? count : ()={throw new Error(...)}())
.then(...)
.catch(...);
```
Regards
On Thu, Oct 9, 2014 at 1:23 PM, Axel Rauschmayer
or a simple utility method
On Thu, Oct 9, 2014 at 6:35 AM, Andrea Giammarchi
andrea.giammar...@gmail.com wrote:
probably not exactly the fat arrow usage you were looking for ... but it
makes it trivial to inline any sort of block
```js
asyncFunc()
.then(count = count = 0 ? count :
On Thu, Oct 9, 2014 at 4:57 PM, John Lenz concavel...@gmail.com wrote:
or a simple utility method
Promise.reject could be used.
```js
asyncFunc()
.then(count = count = 0 ? count : Promise.reject(new Error(...)))
.then(...)
.catch(...)
```
Nathan
John Lenz wrote:
or a simple utility method
Current keyword-anchored statement form does not require parens around
expression to evaluate and throw.
/be
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es
-discuss list es-discuss@mozilla.org
Date: Thu, 9 Oct 2014 14:35:50 +0100
Subject: Re: `throw` as an expression?
probably not exactly the fat arrow usage you were looking for ... but it
makes it trivial to inline any sort of block
```js
asyncFunc()
.then(count = count = 0 ? count : ()={throw new
parens around
expression to evaluate and throw.
/be
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
7 matches
Mail list logo