0.3.0 • Published 5 months ago
@kavsingh/curry-pipe v0.3.0
@kavsingh/curry-pipe
Provides typed curry
and pipe
fns
Have a toy typescript project where perf is not important? Don't want to install bigger, better libraries? Want curry and pipe functions without the hassle of typing them?
Great!
- Horribly naive, optimised for absolutely nothing, but super tiny implementations
- Does not support
lodash
/ramda
style curry placeholders - Anonymous functions everywhere
Sold?
npm i @kavsingh/curry-pipe
Typings are lifted from @types/lodash
Here is the classic simple scenario
import { curry, pipe } from '@kavsingh/curry-pipe';
const add = curry((x: number, y: number) => x + y);
const multiply = curry((x: number, y: number) => x * y);
// infers (x: number) => number
const plus2Times3 = pipe(add(2), multiply(3));
plus2Times3(3); // 15
Dealing with generics needs a BYO signature overload (same with lodash afaik)
import { curry, pipe } from '@kavsingh/curry-pipe';
const takeN: {
(n: number): <X>(xs: X[]) => X[];
<X>(n: number, xs: X[]): X[];
} = curry((n: number, xs: any[]) => xs.slice(0, n));
const range = curry((min: number, max: number) =>
Array.from({ length: max - min }, (_, i) => i + min),
);
// infers (x: number) => number[]
const why = pipe(range(2), takeN(3));
why(10); // [2, 3, 4]
0.3.0
5 months ago
0.2.0-rc.2
9 months ago
0.2.0
9 months ago
0.2.0-rc.0
9 months ago
0.1.4
2 years ago
0.1.3
4 years ago
0.1.2
4 years ago
0.1.1
4 years ago
0.1.0
4 years ago
0.1.0-pubtest.1
4 years ago