1.0.0 • Published 2 years ago

pipeable-es-fns v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

pipeable-es-fns

A typed, curried, ES6+ functions library for pipe style programming.

Use it when

  • You like pipe style programming.
  • But Ramda is too cumbersome for you.
  • And fp-ts introduce too many FP concepts than you want.
  • You just want to use native ES6+ functions with pipe style programming.

Example

import {array, object, pipe} from 'pipeable-es-fns'

const _a = pipe(
  [1, 2, 3],
  array.map((a) => [a, a] as const),
  object.fromEntries
)

const _b = pipe({a: 1, b: 2}, object.entries, object.fromEntries)

Design philosophy

  1. Just curried the ES6+ functions and try to keep others untouched.
  2. Just use the TypeScript official type definitions of ES6+ functions.
  3. Just delegate the implementation to the native ES6+ functions for avoid runtime.
  4. Unlike Ramda, the pipe function accepts data as it's first argument for better type inference.
  5. Organize the functions in a namespace rather than function overload for better type inference.
  6. Doesn't support deprecated methods intentionally.
  7. Encourage to specify the optional arguments implicitly.
  8. Encourage to use one function in one way only.