Support () => {}() syntax?

Olivier Lalonde olalonde at gmail.com
Fri Sep 30 06:38:41 UTC 2016


Do "do expressions" support the "await" keyword?

On Thu, Sep 29, 2016 at 3:59 PM, Rick Waldron <waldron.rick at gmail.com>
wrote:

>
>
> On Thu, Sep 29, 2016 at 3:14 PM Michał Wadas <michalwadas at gmail.com>
> wrote:
>
>> Similar proposal is already here, do expressions.
>>
>
> Additionally...
>
>>
>> On 30 Sep 2016 12:06 a.m., "Olivier Lalonde" <olalonde at gmail.com> wrote:
>>
>>> I occasionally write IIFE to avoid introducing `let` variables, e.g.:
>>>
>>> ```
>>> const thumb = ({ width, height }) => {
>>>   const { w, h } = (() => {
>>>     // if either width or height is set, don't set any default
>>>     if (Number.isInteger(width) || Number.isInteger(height)) {
>>>       return { w: width, h: height }
>>>     }
>>>     return { w: 400, h: 400 }
>>>   })()
>>>   // ...
>>> }
>>> ```
>>>
>>
> Why introduce the function and cognitive overhead?
>
> const thumb = ({ width, height }) => {
>   const w = Number.isInteger(width) ? width : 400;
>   const h = Number.isInteger(height) ? height : 400;
>   // ...
> }
>
>
> Either way, `do` expressions are what you're looking for.
>
>
> Rick
>



-- 
- Oli

Olivier Lalonde
http://www.syskall.com <-- connect with me!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20160929/ba74c008/attachment-0001.html>


More information about the es-discuss mailing list