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.

The proposal is currently Stage 1

💁‍♂️ Stage-1?

The Technical Committee which is concerned with the standardization of ECMAScript (i.e. TC39) has a 5 stage process in place, ranging from stage-0 to stage-4, by which it develops a new language feature.

Stage-1 is the Proposal stage. It signals that the committee is showing interest in the proposal and that it is seeking further investigation on how to tackle it. At this stage the proposal is subject to heavy changes. It is only when a proposal reaches Stage 4 that it is ready to become part of the ECMAScript Specification.

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.

Published by Bramus!

Bramus is a frontend web developer from Belgium, working as a Chrome Developer Relations Engineer at Google. From the moment he discovered view-source at the age of 14 (way back in 1997), he fell in love with the web and has been tinkering with it ever since (more …)

Unless noted otherwise, the contents of this post are licensed under the Creative Commons Attribution 4.0 License and code samples are licensed under the MIT License

Join the Conversation

3 Comments

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.