Created
August 8, 2016 12:01
-
-
Save fayesafe/cd3b30ab67cdad3bc559d2a81e95b561 to your computer and use it in GitHub Desktop.
This file contains 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
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