Pipe Operator (|>) For JavaScript
github.com
Pipe Operator (|>) For JavaScript
1–10 of 437 posts
Re: Pipe Operator (|>) For JavaScript
#2Re: Pipe Operator (|>) For JavaScript
#3Hack proposal
value |> foo(%) for unary function calls,
value |> foo(1, %) for n-ary function calls,
value |> %.foo() for method calls,
value |> % + 1 for arithmetic,
value |> [%, 0] for array literals,
value |> {foo: %} for object literals,
value |> `${%}` for template literals,
value |> new Foo(%) for constructing objects,
value |> await % for awaiting promises,
value |> (yield %) for yielding generator values,
value |> import(%) for calling function-like keywords,
F# proposal value |> x=> x.foo() for method calls,
value |> x=> x + 1 for arithmetic,
value |> x=> [x, 0] for array literals,
value |> x=> ({foo: x}) for object literals,
value |> x=> `${x}` for template literals,
value |> x=> new Foo(x) for constructing objects,
value |> x=> import(x) for calling function-like keywords,
F# proposal would make `await` and `yield` into special syntax cases or not allowed.I'd rather do await/yield the old fashioned way (or slightly complicate the already complex JS syntax rules) than add the weird extra syntax. Arrow functions are elegant and already well-known and well-understood.
Re: Pipe Operator (|>) For JavaScript
#4Re: Pipe Operator (|>) For JavaScript
#5Re: Pipe Operator (|>) For JavaScript
#6Re: Pipe Operator (|>) For JavaScript
#7Re: Pipe Operator (|>) For JavaScript
#8I love the pipe operator in Elixir!
Re: Pipe Operator (|>) For JavaScript
#9I don't see how syntactic sugar makes any sense for javascript. Breaking compatibility is so severe because every browser needs to catch up, yet it doesn't actually enable anything that couldn't be done before.
Same reason async/await was useful far before there was native browser support - you could immediately use it in your codebase and compile to a legacy browser target.
Re: Pipe Operator (|>) For JavaScript
#10I don't see how syntactic sugar makes any sense for javascript. Breaking compatibility is so severe because every browser needs to catch up, yet it doesn't actually enable anything that couldn't be done before.
It lets a transpiler like Babel or Typescript use the new syntax and output the equivalent code that works on older browser. Same reason async/await was useful far before there was native browser support - you could immediately use it in your codebase and compile to a legacy browser target.