Created
January 9, 2024 14:31
-
-
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.
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
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