Skip to content

Instantly share code, notes, and snippets.

@fayesafe
Created August 8, 2016 12:01
Show Gist options
  • Save fayesafe/cd3b30ab67cdad3bc559d2a81e95b561 to your computer and use it in GitHub Desktop.
Save fayesafe/cd3b30ab67cdad3bc559d2a81e95b561 to your computer and use it in GitHub Desktop.
function compose(...funcs) {
if (funcs.length == 1) {
return arg => funcs.shift()(arg)
} else if (funcs.length > 1) {
return arg => funcs.reduceRight((val, func) => func(val), arg)
} else {
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment