Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type Fn<A, B> = (a: A) => B;
- function compose<A, B>(f1: Fn<A, B>): Fn<A, B>;
- function compose<A, B, C>(f1: Fn<B, C>, fn2: Fn<A, B>): Fn<A, C>;
- function compose<A, B, C, D>(
- fn1: Fn<C, D>,
- f2: Fn<B, C>,
- fn3: Fn<A, B>
- ): Fn<A, D>;
- function compose<A, B, C, D, E>(
- fn1: Fn<D, E>,
- fn2: Fn<C, D>,
- f2: Fn<B, C>,
- fn3: Fn<A, B>
- ): Fn<A, E>;
- function compose<A>(...fns: any[]) {
- return (a: A) =>
- fns.reverse().reduce((result, current) => current(result), a);
- }
Add Comment
Please, Sign In to add comment