We're looking for a user researcher to understand the needs of developers and designers. Is this you or someone you know? Check out the post: https://mzl.la/2IGzdXS

Unsere Freiwilligen haben diesen Artikel noch nicht in Deutsch übersetzt. Machen Sie mit und helfen Sie, das zu erledigen!
Sie können den Artikel auch auf English (US) lesen.

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 to create 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').

Syntax

expression |> function

Examples

Chaining function calls

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

Specifications

Specification Status Comment
Pipeline operator draft Stage 1 Not part of the ECMAScript specification yet.

Browser compatibility

FeatureChromeEdgeFirefoxInternet ExplorerOperaSafari
Basic support No No581 No No No
FeatureAndroid webviewChrome for AndroidEdge mobileFirefox for AndroidOpera AndroidiOS SafariSamsung Internet
Basic support No No No581 No No No

1. From version 58: this feature is behind the --enable-pipeline-operator compile flag.

See also

Schlagwörter des Dokuments und Mitwirkende

Schlagwörter: 
Mitwirkende an dieser Seite: cbalisky, DingoEatingFuzz, qwertypants, fscholz
Zuletzt aktualisiert von: cbalisky,