The "Pipeline" Operator - Making multiple function calls look great

Kevin Smith zenparsing at gmail.com
Sat Dec 12 01:08:27 UTC 2015


>
> ```js
> // Assume fs.readFile is an `async` function
> async function runTask () {
>   './index.txt'
>     |> await fs.readFile
>     |> file => file
>        .split('\n')
>        .map(fs.readFile)
>     |> await Promise.all
>     |> all => all.join("\n")
>     |> console.log
> }
> ```
>

This doesn't work unless you special case the semantics of await
expressions.  With the current semantics, `await fs.readFile` will just
await `fs.readFile` not the result of applying it.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20151212/6099b4c1/attachment.html>


More information about the es-discuss mailing list