Last active
March 16, 2016 12:07
-
-
Save carlesba/e3ed6d80677e2f70eb17 to your computer and use it in GitHub Desktop.
Compose functions
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
const compose = (...fns) => (...args) => fns.reverse().reduce((acc, fn, index) => { | |
if (index) return fn(acc) | |
else return fn.apply(this, acc) | |
}, args) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment