Skip to content

Instantly share code, notes, and snippets.

@eiriklv
Created October 24, 2016 21:46
Show Gist options
  • Save eiriklv/bc29a8170f59a0d82937324b7ca78584 to your computer and use it in GitHub Desktop.
Save eiriklv/bc29a8170f59a0d82937324b7ca78584 to your computer and use it in GitHub Desktop.
Compose
function composeLeft(...funcs) {
return function(input) {
return funcs.reduce((result, func) => {
return func(result);
}, input);
}
}
function composeRight(...funcs) {
return function(input) {
return funcs.reverse().reduce((result, func) => {
return func(result);
}, input);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment