--- source: crates/biome_formatter_test/src/snapshot_builder.rs info: js/babel-plugins/pipeline-operator-fsharp.js --- # Input ```js // https://babeljs.io/docs/en/babel-plugin-proposal-pipeline-operator // https://github.com/valtech-nyc/proposal-fsharp-pipelines promise |> await |> x => doubleSay(x, ', ') |> capitalize |> x => x + '!' |> x => new User.Message(x) |> x => stream.write(x) |> await |> console.log; const result = exclaim(capitalize(doubleSay("hello"))); result //=> "Hello, hello!" const result = "hello" |> doubleSay |> capitalize |> exclaim; result //=> "Hello, hello!" const person = { score: 25 }; const newScore = person.score |> double |> n => add(7, n) |> n => boundScore(0, 100, n); newScore //=> 57 // As opposed to: let newScore = boundScore(0, 100, add(7, double(person.score))); ``` # Prettier differences ```diff --- Prettier +++ Biome @@ -3,25 +3,32 @@ promise |> await - |> (x) => doubleSay(x, ", ") + |> x +=> doubleSay(x, ', ') |> capitalize - |> (x) => x + "!" - |> (x) => new User.Message(x) - |> (x) => stream.write(x) + |> x => x + '!' + |> x => new User.Message(x) + |> x => stream.write(x) |> await - |> console.log; + |> console.log const result = exclaim(capitalize(doubleSay("hello"))); result; //=> "Hello, hello!" -const result = "hello" |> doubleSay |> capitalize |> exclaim; +const result = "hello" + |> doubleSay + |> capitalize + |> exclaim; result; //=> "Hello, hello!" const person = { score: 25 }; -const newScore = - person.score |> double |> (n) => add(7, n) |> (n) => boundScore(0, 100, n); +const newScore = person.score + |> double + |> n +=> add(7, n) + |> n => boundScore(0, 100, n) newScore; //=> 57 ``` # Output ```js // https://babeljs.io/docs/en/babel-plugin-proposal-pipeline-operator // https://github.com/valtech-nyc/proposal-fsharp-pipelines promise |> await |> x => doubleSay(x, ', ') |> capitalize |> x => x + '!' |> x => new User.Message(x) |> x => stream.write(x) |> await |> console.log const result = exclaim(capitalize(doubleSay("hello"))); result; //=> "Hello, hello!" const result = "hello" |> doubleSay |> capitalize |> exclaim; result; //=> "Hello, hello!" const person = { score: 25 }; const newScore = person.score |> double |> n => add(7, n) |> n => boundScore(0, 100, n) newScore; //=> 57 // As opposed to: let newScore = boundScore(0, 100, add(7, double(person.score))); ``` # Errors ``` pipeline-operator-fsharp.js:5:4 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × Expected an expression for the left hand side of the `>` operator. 4 │ promise > 5 │ |> await │ ^ 6 │ |> x => doubleSay(x, ', ') 7 │ |> capitalize i This operator requires a left hand side value pipeline-operator-fsharp.js:6:3 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × Expected an unary expression but instead found '|'. 4 │ promise 5 │ |> await > 6 │ |> x => doubleSay(x, ', ') │ ^ 7 │ |> capitalize 8 │ |> x => x + '!' i Expected an unary expression here. 4 │ promise 5 │ |> await > 6 │ |> x => doubleSay(x, ', ') │ ^ 7 │ |> capitalize 8 │ |> x => x + '!' pipeline-operator-fsharp.js:6:4 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × Expected an expression for the left hand side of the `>` operator. 4 │ promise 5 │ |> await > 6 │ |> x => doubleSay(x, ', ') │ ^ 7 │ |> capitalize 8 │ |> x => x + '!' i This operator requires a left hand side value pipeline-operator-fsharp.js:6:8 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × Expected a semicolon or an implicit semicolon after a statement, but found none 4 │ promise 5 │ |> await > 6 │ |> x => doubleSay(x, ', ') │ ^^ 7 │ |> capitalize 8 │ |> x => x + '!' i An explicit or implicit semicolon is expected here... 4 │ promise 5 │ |> await > 6 │ |> x => doubleSay(x, ', ') │ ^^ 7 │ |> capitalize 8 │ |> x => x + '!' i ...Which is required to end this statement 2 │ // https://github.com/valtech-nyc/proposal-fsharp-pipelines 3 │ > 4 │ promise │ ^^^^^^^ > 5 │ |> await > 6 │ |> x => doubleSay(x, ', ') │ ^^^^^^^ 7 │ |> capitalize 8 │ |> x => x + '!' pipeline-operator-fsharp.js:18:4 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × Expected an expression for the left hand side of the `>` operator. 17 │ const result = "hello" > 18 │ |> doubleSay │ ^ 19 │ |> capitalize 20 │ |> exclaim; i This operator requires a left hand side value pipeline-operator-fsharp.js:19:4 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × Expected an expression for the left hand side of the `>` operator. 17 │ const result = "hello" 18 │ |> doubleSay > 19 │ |> capitalize │ ^ 20 │ |> exclaim; 21 │ i This operator requires a left hand side value pipeline-operator-fsharp.js:20:4 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × Expected an expression for the left hand side of the `>` operator. 18 │ |> doubleSay 19 │ |> capitalize > 20 │ |> exclaim; │ ^ 21 │ 22 │ result //=> "Hello, hello!" i This operator requires a left hand side value pipeline-operator-fsharp.js:27:4 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × Expected an expression for the left hand side of the `>` operator. 26 │ const newScore = person.score > 27 │ |> double │ ^ 28 │ |> n => add(7, n) 29 │ |> n => boundScore(0, 100, n); i This operator requires a left hand side value pipeline-operator-fsharp.js:28:4 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × Expected an expression for the left hand side of the `>` operator. 26 │ const newScore = person.score 27 │ |> double > 28 │ |> n => add(7, n) │ ^ 29 │ |> n => boundScore(0, 100, n); 30 │ i This operator requires a left hand side value pipeline-operator-fsharp.js:28:8 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × Expected a semicolon or an implicit semicolon after a statement, but found none 26 │ const newScore = person.score 27 │ |> double > 28 │ |> n => add(7, n) │ ^^ 29 │ |> n => boundScore(0, 100, n); 30 │ i An explicit or implicit semicolon is expected here... 26 │ const newScore = person.score 27 │ |> double > 28 │ |> n => add(7, n) │ ^^ 29 │ |> n => boundScore(0, 100, n); 30 │ i ...Which is required to end this statement 24 │ const person = { score: 25 }; 25 │ > 26 │ const newScore = person.score │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > 27 │ |> double > 28 │ |> n => add(7, n) │ ^^^^^ 29 │ |> n => boundScore(0, 100, n); 30 │ ```