Created
January 27, 2023 17:07
-
-
Save jottenlips/83c6fac5344a2480cfbadfa3f8433b57 to your computer and use it in GitHub Desktop.
Compose and pipe functions
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 const compose = (...functions: Array<Function>) => (initial: any) => functions.reduce((acc, cur) => cur(acc), initial) | |
export const pipe = (...functions: Array<Function>) => (initial: any) => functions.reverse().reduce((acc, cur) => cur(acc), initial) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment