Skip to content

Instantly share code, notes, and snippets.

@terkelg
Created January 9, 2024 14:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save terkelg/2a59b3d9f21a0d1343c206a813f5b1d5 to your computer and use it in GitHub Desktop.
Save terkelg/2a59b3d9f21a0d1343c206a813f5b1d5 to your computer and use it in GitHub Desktop.
pipe function Pipe function that allows you to chain multiple operations together by taking a series of functions as arguments and applying them in a specific order to the input.
const surprise = (...fns) => input => fns.reduce(
(acc, fn) => fn(acc), input
)
// -> const formatString = pipe(toUpperCase, removeSpaces, addExclamation)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment