Skip to content

Instantly share code, notes, and snippets.

@cherihung
Created May 28, 2018 23:13
Show Gist options
  • Save cherihung/a12908c0445b5678a3a9b2e696e98493 to your computer and use it in GitHub Desktop.
Save cherihung/a12908c0445b5678a3a9b2e696e98493 to your computer and use it in GitHub Desktop.
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