Skip to content

Instantly share code, notes, and snippets.

@danrspencer
Last active June 29, 2017 11:04
Show Gist options
  • Save danrspencer/c77e17ff367ffcc76b8b7e674fa5781f to your computer and use it in GitHub Desktop.
Save danrspencer/c77e17ff367ffcc76b8b7e674fa5781f to your computer and use it in GitHub Desktop.
Some functions to allow a more functional paradigm in js
export const compose = (...fns) =>
fns.reduce((f, g) => (...args) => f(g(...args)));
export const pipe = (...fns) => compose.apply(compose, fns.reverse());
export const partial = (fn, [args]) => (...moreArgs) =>
fn(...[args, ...moreArgs]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment