Skip to content

Instantly share code, notes, and snippets.

@RoryCombe
Created November 20, 2018 11:54
Show Gist options
  • Save RoryCombe/4ed3cf1c6070f798853d40099df1973f to your computer and use it in GitHub Desktop.
Save RoryCombe/4ed3cf1c6070f798853d40099df1973f to your computer and use it in GitHub Desktop.
JavaScript/ES6 Functional utilities
const flip = fn => (a, b) => fn(b, a);
const apply = (func, val) => func(val);
const flipApply = flip(apply);
const pipe = (...args) => x => args.reduce(flipApply, x);
const compose = (...args) => pipe(...args.reverse());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment