ESNext Proposal: The Pipeline Operator

The pipeline operator is essentially a useful syntactic sugar on a function call with a single argument. In other words, sqrt(64) is equivalent to 64 |> sqrt.

This allows for greater readability when chaining several functions together.

With the Pipeline Operator, one could rewrite this …

let result = exclaim(capitalize(doubleSay("hello")));

… to this (think Unix pipes!):

let result = "hello"
  |> doubleSay
  |> capitalize
  |> exclaim;

The proposal also caters for functions with multiple arguments with arrow functions or partial application.

ESNext Proposal: The Pipeline Operator →

Related: Whilst this proposed operator only gets me lightly excited, one that does get me very excited is The Null Propagation Operator. You should definitely check it out.

Join the Conversation

1 Comment

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.