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.

Elsewhere ,

Leave a Reply

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