4 ms·
TC39 Pipeline Operator
- linkdd 5y agoI fell in love with Elixir's pipeline operator. It would be a joy to see it come to Javascript/Typescript. I think the explicit "^" in one of the proposals can be a good idea. Python's badly designed interface comes to mind: (lambda i: i * 2) |> map([1, 2, 3]) vs [1, 2, 3] |> map(lambda i: i * 2, ^) But since "^" is already a binary operator, I would rather use "&1" (like in Elixir). This would have the benefit of being consistent with a later partial function application syntax: const add = (a, b, c) => a + b + c const f = add(1, &1, &2) f(2, 3) === 6 Note also that for promises, I think, a global then function should be provided: const promise = new Promise(...) |> then(&1, async result => ...)