This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
The experimental pipeline operator |>
(currently at stage 1) allows the creation of chained function calls in a readable manner. Basically, the pipeline operator provides syntactic sugar on a function call with a single argument allowing you to write
'%21' |> decodeURI
instead of decodeURI('%21')
.
expression |> function
The pipeline operator can improve readability when chaining several functions.
const double = (n) => n * 2; const increment = (n) => n + 1; // without pipeline operator double(increment(double(double(5)))); // 42 // with pipeline operator 5 |> double |> double |> increment |> double; // 42
Specification | Status | Comment |
---|---|---|
Pipeline operator draft | Stage 1 | Not part of the ECMAScript specification yet. |
Desktop | ||||||
---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | |
Basic support | No | No | 58
|
No | No | No |
Mobile | |||||||
---|---|---|---|---|---|---|---|
Android webview | Chrome for Android | Edge Mobile | Firefox for Android | Opera for Android | iOS Safari | Samsung Internet | |
Basic support | No | No | No | 58
|
No | No | No |
Server | |
---|---|
Node.js | |
Basic support | No |
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Pipeline_operator