Skip to content

Instantly share code, notes, and snippets.

@jottenlips
Created January 27, 2023 17:07
Show Gist options
  • Save jottenlips/83c6fac5344a2480cfbadfa3f8433b57 to your computer and use it in GitHub Desktop.
Save jottenlips/83c6fac5344a2480cfbadfa3f8433b57 to your computer and use it in GitHub Desktop.
Compose and pipe functions
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