Skip to content

Instantly share code, notes, and snippets.

@chalu
Created July 18, 2019 18:08
Show Gist options
  • Save chalu/d2ee6e5bbf490b218dbcb645ba76e9d5 to your computer and use it in GitHub Desktop.
Save chalu/d2ee6e5bbf490b218dbcb645ba76e9d5 to your computer and use it in GitHub Desktop.
const chain = (...fns) => {
return (data) => {
return fns.reduce((computed, fn) => {
return fn(computed);
}, data);
};
};
// use as
// chain(steps)(initialData)
// or as
// const algol = chain(steps);
// const discovery = algol(initialData);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment