3 ms·
I've been experimenting with this via a babel plugin for a while. The difference in ergonomics is huge, and it's readable too! At first, I was so excited to t
by egeozcan 5y ago
I've been experimenting with this via a babel plugin for a while.
The difference in ergonomics is huge, and it's readable too!
At first, I was so excited to try it, I wanted to "simulate it" via some library I developed: https://github.com/egeozcan/ppipe https://github.com/egeozcan/ppipe Then I realized it was super hard to add typings for it (I use Typescript nearly exclusively these days).
Anyway, I can't wait this to be adopted by Typescript!
- ricardobeat 5y agoThis idea has been toyed with for a decade. Im pretty sure lodash still has a pipe method somewhere. I actually prefer the `.pipe` function over the proposed operator, but we’ve had that available for 10+ years with very little adoption. Unless the new operator was wildly easier to use (it’s not), that adoption says everything we need to know about the need to add this feature to JS.
- egeozcan 5y agoI did develop a library and am still of the opinion that the native implementation is vastly superior. You cannot use .pipe unless you break other code and start changing prototypes of all the things, or you wrap the result every time. So when I'm writing an expression, I need to go back and write pipe(expression).pipe(... Also the placeholder is much easier to use than using something like my solution (const _ = pipe._) for it. You don't need to remember importing/defining it! I was even toying with a crazier version (notice the extra p, yeah I suck at naming things): https://github.com/egeozcan/pppipe/ https://github.com/egeozcan/pppipe/ The only reason that exists is to prevent the clutter of writing .pipe all the time. Yet another reason is, you'd get autocomplete with a native implementation, and also TS support! Also, it's been toyed for surely more than a decade, even my library is 6 years old (older if you count my previous non-public attempts).
- mirekrusin 5y agoYou can type it, take a look at pipe and pipe1 in [0]. [0] https://github.com/preludejs/generator/tree/master/src https://github.com/preludejs/generator/tree/master/src
- egeozcan 5y agoMine is a bit more complicated, unfortunately (me from 6 years ago had so much ambition, and implemented all the things) Also this: https://github.com/preludejs/generator/blob/master/src/pipe.ts https://github.com/preludejs/generator/blob/master/src/pipe.... Wait, what? :)) I'm not ready to deal with something like that (just to make sure it doesn't come as arrogant, I mean I just don't trust myself)
- mirekrusin 5y agoYes, pyramid of hell. I said it "can be typed", I didn't say it's "pretty"! :)
- klavinski 5y agoYou can use this pull review [0] as a NPM build with: "typescript": "npm:@typescript-deploys/pr-build@4.6.0-pr-43617-23" [0] https://github.com/microsoft/TypeScript/pull/43617 https://github.com/microsoft/TypeScript/pull/43617