Hacker News new | past | comments | ask | show | jobs | submit login

The strength of the pipeline operators comes when you have to do method chaining things like:

  const foo = capitalize(underline(reverse(exclaim(indent(value)))));
I already forgot the amount of parentheses I needed to close with while typing that.



  value.indent()
    .exclaim()
    .reverse()
    .underline()
    .capitalize()
There’s always the OOP version of method chaining!


This won't look as good when you include all the boilerplate which defines those methods, and which needs to be repeated or otherwise included for every "value" type. You don't have to worry about this when they are pure utility functions.


Which is great until Prettier, in its infinite wisdom, decides it's better to stick four of these function invocations on one line and two on the next, so you have an obnoxious mishmash of tokens!


Which is a problem of Prettier. I wish for the day that someone builds rustfmt but for Typescript, I will happily leave Prettier and StandardJS behind.

I think it could be done today with a (big) number of ESLint plugins.


No worries your ide will help you for the parentheses.


IDEs and linters should not be a crutch methinks because not everyone uses the same IDE or text editor. Either way, it will still be awkward to read.

Better that you either avoid that pattern or at least indent it in such a way that its not so visually confusing. Or yknow use a pipe operator.


People do tend to use the same linter and LSP. That’s why they exist in the first place.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: