Created
May 28, 2018 23:13
-
-
Save cherihung/a12908c0445b5678a3a9b2e696e98493 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
const compose = (...functions) => x => functions.reduce((acc, fn) => fn(acc), x); | |
// compose(fn1, fn2, fn3) | |
const pipe = functions => data => { | |
return functions.reduce( | |
(value, func) => func(value), | |
data | |
); | |
}; | |
/* const pipeline = pipe([ | |
x => x * 2, | |
x => x + 10, | |
x => x > 100, | |
b => !b | |
]); */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment