Last active
November 8, 2021 16:42
-
-
Save christianwish/eb01dcc6525bdfd1d5e6f0d12547af8f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export type COMPOSE = <T>(fn1: (a: T) => T, ...fns: Array<(a: T) => T>) => | |
(a: T) => T | |
export const compose: COMPOSE = (fn1, ...fns) => | |
fns.reduce( | |
(prevFn, nextFn) => | |
(value) => prevFn(nextFn(value)), | |
fn1 | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment