JS Pipeline Operator

What are your thoughts on the new Pipeline operator being proposed for JavaScript?

Currently they are working out the flavor of the syntax. Looks like it’s between Hack and F# syntax.

Hack Flavor

Provides explicit placeholders. The operati…


This content originally appeared on DEV Community 👩‍💻👨‍💻 and was authored by Wade Zimmerman

What are your thoughts on the new Pipeline operator being proposed for JavaScript?

Currently they are working out the flavor of the syntax. Looks like it's between Hack and F# syntax.

Hack Flavor

Provides explicit placeholders. The operation pipes the previous result to the parameter holding the % sign.

value |> one(%) |> two(%) |> three(%)

value 
|> one('foo', %) 
|> two('bar', %) 
|> three('baz', %)

F# Flavor

Provides implicit syntax but could easily be paired with lambdas for more complex pipelines.

value |> one |> two |> three

value 
|> x => one('foo', x) 
|> x => two('bar', x) 
|> x => three('baz', x)

My Hot Take

Personally I don't like the Hack Flavor. I mainly crave the implicit syntax from F#. Adding an explicit special character to act as a placeholder seems rather annoying.

However, it sounds like the F# flavor comes with some performance pitfalls and could be more difficult to use with async code.

What do you think?


This content originally appeared on DEV Community 👩‍💻👨‍💻 and was authored by Wade Zimmerman


Print Share Comment Cite Upload Translate Updates
APA

Wade Zimmerman | Sciencx (2023-01-20T23:40:10+00:00) JS Pipeline Operator. Retrieved from https://www.scien.cx/2023/01/20/js-pipeline-operator/

MLA
" » JS Pipeline Operator." Wade Zimmerman | Sciencx - Friday January 20, 2023, https://www.scien.cx/2023/01/20/js-pipeline-operator/
HARVARD
Wade Zimmerman | Sciencx Friday January 20, 2023 » JS Pipeline Operator., viewed ,<https://www.scien.cx/2023/01/20/js-pipeline-operator/>
VANCOUVER
Wade Zimmerman | Sciencx - » JS Pipeline Operator. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2023/01/20/js-pipeline-operator/
CHICAGO
" » JS Pipeline Operator." Wade Zimmerman | Sciencx - Accessed . https://www.scien.cx/2023/01/20/js-pipeline-operator/
IEEE
" » JS Pipeline Operator." Wade Zimmerman | Sciencx [Online]. Available: https://www.scien.cx/2023/01/20/js-pipeline-operator/. [Accessed: ]
rf:citation
» JS Pipeline Operator | Wade Zimmerman | Sciencx | https://www.scien.cx/2023/01/20/js-pipeline-operator/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.