Skip to content

Instantly share code, notes, and snippets.

@carlesba
Last active March 16, 2016 12:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carlesba/e3ed6d80677e2f70eb17 to your computer and use it in GitHub Desktop.
Save carlesba/e3ed6d80677e2f70eb17 to your computer and use it in GitHub Desktop.
Compose functions
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