Created
January 24, 2023 19:03
-
-
Save andresgcarmona/c36781ecbc2a9932cca4a3388483882a to your computer and use it in GitHub Desktop.
Javascript pipe function
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 pipe = (...fns) => input => fns.reduce( | |
(acc, fn) => fn(acc), input | |
) | |
const formatString = pipe(toUpperCase, removeSpaces, addExclamation) | |
formatString('Hello World') // HELLOWORLD! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment