Hacker News new | ask | show | jobs
by ziml77 1546 days ago
That's worse because now you have to find the innermost function and then walk back outwards. It gets especially ugly when the calls require other parameters

    let x = anotherThing(
      somethingElse(
        something(
         x, y, z
        ), 1, 2, 3
      ), "a", "b", "c"
    );
Or maybe this looks cleaner?

    let x = anotherThing(
      somethingElse(
        something(x, y, z),
        1, 2, 3
      ),
      "a", "b", "c"
    );
Neither is easy to follow.
1 comments

I take you are no big fan of Lisp? /s

Well, actually I agree with you - sometimes. I have actually written helper functions to get similar pipeline processing capabilities in js.

    function pipe(...args) {
      return args.reduce((x, fn) => fn(x), null);
    }

    pipe(
      () => 2,
      (x) => 7*x,
      console.log
    )