Skip to content

Instantly share code, notes, and snippets.

@benedyktdryl
Created February 15, 2017 13:22
Show Gist options
  • Save benedyktdryl/239ae338fbd17250577e8150b54ee0d7 to your computer and use it in GitHub Desktop.
Save benedyktdryl/239ae338fbd17250577e8150b54ee0d7 to your computer and use it in GitHub Desktop.
Simple composition helper for FP in ES6.
const compose = (...callbacks) => (
(...args) => (
callbacks.reduce((prev, callback) => (
[callback(...prev)]
), args)
)
);
compose(
(x) => (x * 2),
(x) => (x * 3),
(x) => (x * 4)
)(2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment