or a simple utility method
On Thu, Oct 9, 2014 at 6:35 AM, Andrea Giammarchi < [email protected]> 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 : ()=>{throw new Error(...)}()) > .then(...) > .catch(...); > ``` > > Regards > > > On Thu, Oct 9, 2014 at 1:23 PM, Axel Rauschmayer <[email protected]> wrote: > >> 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(...) >> .catch(...); >> ``` >> >> Could `throw` be turned into an expression? >> >> -- >> Dr. Axel Rauschmayer >> [email protected] >> rauschma.de >> >> >> >> >> _______________________________________________ >> es-discuss mailing list >> [email protected] >> https://mail.mozilla.org/listinfo/es-discuss >> >> > > _______________________________________________ > es-discuss mailing list > [email protected] > https://mail.mozilla.org/listinfo/es-discuss > >
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

