Created
August 6, 2018 19:01
-
-
Save marekdano/331a714420b0450fa1ef1412b553e753 to your computer and use it in GitHub Desktop.
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
// reference https://medium.com/javascript-scene/master-the-javascript-interview-what-is-function-composition-20dfb109a1a0 | |
const pipe = (...fns) => x => fns.reduce((v, f) => f(v), x); | |
const fn1 = s => s.toLowerCase(); | |
const fn2 = s => s.split('').reverse().join(''); | |
const fn3 = s => s + '!' | |
const newFunc = pipe(fn1, fn2, fn3); | |
const result = newFunc('Time'); // emit! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment