unsplash / pipe-ts

34 stars 4 forks source link

Avoid intermediate array creation while reducing functions. #13

Open Kapelianovych opened 1 year ago

Kapelianovych commented 1 year ago

Hi šŸ‘‹ First of all, thanks for the package. I am using it a lot despite it being quite old.

I would like to suggest some small improvements to the package:

  1. Since TSLint is deprecated I replaced it with ESLint + TypeScript plugin.
  2. I noticed that for every reducing step an intermediate array is created and this unnecessary initialisation may be avoided if we will pull out the first function from the fns parameter and execute it with rest arguments beforehand. Because the pipe function cannot be executed without any arguments (at least, it doesn't make any sense), there is potentially no breaking change.
  3. All array constraints and type were declared as readonly, because readonly array is broader one than a mutable array. Well, it mostly depends on ones preference.
  4. The @ts-ignore statement were replaced with more verbose @ts-expect-error.
  5. All dependencies were updated.
  6. CI uses the newer Ubuntu Focal OS now instead of the Ubuntu Xenial which contains an outdated GLIBC library version (Node's dependency).