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

Felipe Nascimento de Moura felipenmoura at gmail.com
Mon Dec 14 02:32:09 UTC 2015


my 50 cents.

I think it is interesting to be added
I think this should not really concern to await implementations (would,
indeed, get weirder and more complicated)!
I don't think this has *anything* to do with bind! No "this" is touched
with that!
I don't think it has anything to do with chaining either.

How I see it:

```js
// consider:
function getUserName () { /* ... */ }
function capitalize (str) { /* ... */ }
function trim (str) { /* ... */ }
function splitBySpaces (str) { /* ... */ }
```

```js
// Using PO:
console.log( getUserName() |> capitalize |> trim |> splitBySpaces );
```

```js
// NOT using PO:
let name = getUserName();
name = capitalize(name);
name = trim(name);
console.log( splitBySpaces(name) );

// OR

console.log( splitBySpaces( trim( capitalize( getUserName() ) ) ) );

```

This is not related with "this", nor with chaining(once it can be used with
any function, even when, as in this case, returning strings). This is not
like "then" either, once it is not temporal, but way easier to read and
understand!

Therefore...I don't think this should be consider to work with await. I
don't they belong to the same realm!

Although, I believe this would work too:

```js
// imagine getUserName and trim are async

console.log(await getUserName() |> capitalize |> await trim |>
splitBySpaces );
```

Thanks for your time :)






On Sun, Dec 13, 2015 at 5:39 AM, Alican Çubukçuoğlu <
alicancubukcuoglu at gmail.com> wrote:

> > I think you may be misunderstanding how the PO works. Specifically your
> example here:
>
> Just a typo. Let me list my concerns:
> - Supporting await makes things unnecessarily complicated.
> - Calling functions with more than one parameter is weird.
> - Looks like use cases are already covered by FBS.
>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>


-- 
*Felipe N. Moura*
Senior Web Developer and System Analyst.

Website:  http://felipenmoura.com
Twitter:    @felipenmoura <http://twitter.com/felipenmoura>
LinkedIn: http://goo.gl/qGmq

Meet some of my projects:
BrazilJS Conference <http://braziljs.com.br/>  |  BrazilJS Foundation
<http://braziljs.org>
---------------------------------
*Changing  the  world*  is the least I expect from  myself!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20151214/11db3fb9/attachment.html>


More information about the es-discuss mailing list