aboutsummaryrefslogtreecommitdiff
path: root/files/fr/web/javascript/reference/operators/pipeline_operator
diff options
context:
space:
mode:
authorFlorian Merz <me@fiji-flo.de>2021-02-11 12:36:08 +0100
committerFlorian Merz <me@fiji-flo.de>2021-02-11 12:36:08 +0100
commit39f2114f9797eb51994966c6bb8ff1814c9a4da8 (patch)
tree66dbd9c921f56e440f8816ed29ac23682a1ac4ef /files/fr/web/javascript/reference/operators/pipeline_operator
parent8260a606c143e6b55a467edf017a56bdcd6cba7e (diff)
downloadtranslated-content-39f2114f9797eb51994966c6bb8ff1814c9a4da8.tar.gz
translated-content-39f2114f9797eb51994966c6bb8ff1814c9a4da8.tar.bz2
translated-content-39f2114f9797eb51994966c6bb8ff1814c9a4da8.zip
unslug fr: move
Diffstat (limited to 'files/fr/web/javascript/reference/operators/pipeline_operator')
-rw-r--r--files/fr/web/javascript/reference/operators/pipeline_operator/index.html72
1 files changed, 72 insertions, 0 deletions
diff --git a/files/fr/web/javascript/reference/operators/pipeline_operator/index.html b/files/fr/web/javascript/reference/operators/pipeline_operator/index.html
new file mode 100644
index 0000000000..2763987971
--- /dev/null
+++ b/files/fr/web/javascript/reference/operators/pipeline_operator/index.html
@@ -0,0 +1,72 @@
+---
+title: Tube
+slug: Web/JavaScript/Reference/Opérateurs/Tube
+tags:
+ - Experimental
+ - JavaScript
+ - Opérateur
+ - Reference
+translation_of: Web/JavaScript/Reference/Operators/Pipeline_operator
+---
+<div>{{jsSidebar("Operators")}} {{SeeCompatTable}}</div>
+
+<p>L'opérateur expérimental tube (ou <em>pipeline</em> en anglais) <strong><code>|&gt;</code></strong> (actuellement au niveau 1 des propositions) permet de créer des chaînes d'appel de fonctions de façon lisible. En fait, cet opérateur fournit un sucre syntaxique pour les appels de fonction avec un seul argument. On pourrait donc écrire :</p>
+
+<pre class="brush: js">let url = "%21%" |&gt; decodeURI;</pre>
+
+<p>qui correspond exactement à :</p>
+
+<pre class="brush: js">let url = decodeURI("%21%");</pre>
+
+<h2 id="Syntaxe">Syntaxe</h2>
+
+<pre class="syntaxbox">expression |&gt; function</pre>
+
+<p>La valeur de <code>expression</code> est passé à <code>function</code> comme unique paramètre.</p>
+
+<h2 id="Exemples">Exemples</h2>
+
+<h3 id="Enchaîner_des_appels_de_fonction">Enchaîner des appels de fonction</h3>
+
+<p>L'opérateur tube peut améliorer la lisibilité lorsqu'on enchaîne plusieurs fonctions.</p>
+
+<pre class="brush: js">const doubler = (n) =&gt; n * 2;
+const incrementer = (n) =&gt; n + 1;
+
+// Sans l'opérateur tube
+doubler(incrementer(doubler(10))); // 42
+
+// Avec l'opérateur tube
+10 |&gt; doubler |&gt; incrementer |&gt; doubler; // 42
+</pre>
+
+<h2 id="Spécifications">Spécifications</h2>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Spécification</th>
+ <th scope="col">État</th>
+ <th scope="col">Commentaires</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td><a href="https://tc39.github.io/proposal-pipeline-operator/#sec-intro">Brouillon de spécification pour la proposition de l'opérateur tube</a></td>
+ <td>Niveau 1</td>
+ <td>Ne fait actuellement pas partie de la spécification ECMAScript.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Compatibilité_des_navigateurs">Compatibilité des navigateurs</h2>
+
+<div class="hidden">Ce tableau de compatibilité a été généré à partir de données structurées. Si vous souhaitez contribuer à ces données, n'hésitez pas à envoyer une <em>pull request</em> sur <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a>.</div>
+
+<p>{{Compat("javascript.operators.pipeline")}}</p>
+
+<h2 id="Voir_aussi">Voir aussi</h2>
+
+<ul>
+ <li><a href="https://github.com/tc39/proposals">Les propositions au TC39</a></li>
+</ul>