Created
May 14, 2018 10:45
-
-
Save renatobenks-zz/694cbc00da6e3ecab0140585046d491c to your computer and use it in GitHub Desktop.
A compose function
This file contains hidden or 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 === 0) return arg => arg; | |
if (funcs.length === 1) return funcs[0]; | |
return funcs.reduce((a, b) => (...args) => a(b(...args))) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment