3 ms·
The use of the term "pipe" definitely implies a sequential pipeline, and in that sense I agree with the author. But it really only manifests after a few functi
by nkozyra 5y ago
The use of the term "pipe" definitely implies a sequential pipeline, and in that sense I agree with the author.
But it really only manifests after a few function calls, at which point you're forced to find the initial value and recursively parse the methods. The example is probably unrealistic and not real world, but it's a speed bump I've encountered in real code.
Per your example - which is definitely less abstract - it would still feel more intuitive to see
5 | triple() | double() | halve ()
My issue is the syntax in the proposal, which may feel like another language's implementation, but doesn't really feel like JavaScript. Mentally thinking about JS as an "everything is an object" paradigm, just having a breakout-and-apply chain that looked closer to a dot operator would be more native feeling.
('25').|parseInt(%).|math.Sqrt(%)
Other languages imply the pipe "direction" pass-off with syntax like -> but JS has traditionally eschewed that with more apply-transformation-in-place syntax.