Created
December 20, 2016 22:15
-
-
Save WillsonSmith/50a83d943f93b45bc677a0bab69ce85c to your computer and use it in GitHub Desktop.
compose functions in JS
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) { | |
return function (value) { | |
return funcs.reverse().reduce(function(previous, current) { | |
return previous.call(this, current(value)); | |
}); | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment