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

Marius Gundersen gundersen at gmail.com
Mon Dec 14 13:59:10 UTC 2015


Do we really need to add support for await in a pipeline syntax sugar when
there already is a piping support in `.then()`? If you need to await
something in that chain, then just use `.then()`.

```js
let result = await fs.readFile('index.txt')
  .then(aSingleParamFunction)
  .then(anotherSingleParamFunction)
  .then(x => multiParamFunction(x, 10));
```

I really don't see much gain in adding this syntax when there is already a
FBS proposal that covers most of the cases. The pipe operator only supports
single param functions. With multiple params you either need to use
fat-arrow (while FBS handles multiple params) or you need a special
function that is curryable. So now we either need functions that is
curryable (for |>) or a function that relies on the `this` value (for FBS),
so libraries will probably need to be specially written for whichever
proposal is added to the spec. It looks to me like FBS adds a lot more
value than |> does.


On Mon, Dec 14, 2015 at 2:05 PM, Bruno Jouhier <bjouhier at gmail.com> wrote:

> `await` could be handled by with contextual lexing: handling `|> await` as
> a single keyword.
>
> Another solution would be to collapse the two into a variant of the
> pipeline operator: `|await>`, `|!>`, ...
>
> This could be an opportunity to revive the syntax sugar that was proposed
> in http://wiki.ecmascript.org/doku.php?id=strawman:concurrency
>
> ```js
> // concurrency strawman
> lines = fs.readFile!('./index.txt').split('\n');
> // pipeline operator
> lines = './index.txt' |!> fs.readFile |> str => str.split('\n')
> ```
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20151214/e5df99f5/attachment.html>


More information about the es-discuss mailing list