2 ms·
I was playing with it, and you can do this, which looks a little better. const greeting = pipe('hello'); greeting | upper | ex('!!!'); await greeti
by nticompass 1y ago
I was playing with it, and you can do this, which looks a little better.
const greeting = pipe('hello');
greeting | upper | ex('!!!');
await greeting.run(); // → "HELLO!!!"
Since it uses the "Symbol.toPrimitive" method, you can use any operator (not just "bitwise OR" (|)).
const greeting = pipe('hello');
greeting / upper * ex('!!!');
await greeting.run(); // → "HELLO!!!"
- urvader 1y agoThanks for pointing this out, I updated the examples now to this syntax.
- hinkley 1y agoThat’s not better because it implies these are all destructive function calls. Mutating your inputs is not functional programming. And pipes are effectively compact list comprehensions. Comprehensions without FP is Frankensteinian.