Skip to content

Instantly share code, notes, and snippets.

@iamstarkov
Created November 17, 2017 22:59
Show Gist options
  • Save iamstarkov/0c25f23af3e6f4b4fa6d0e402656733e to your computer and use it in GitHub Desktop.
Save iamstarkov/0c25f23af3e6f4b4fa6d0e402656733e to your computer and use it in GitHub Desktop.
const curry = fn => (...args) => args.length < fn.length
? (...rest) => curry(fn)(...args, ...rest)
: fn(...args);
const applyTo = curry( (x, fn) => fn(x) );
const pipe = (headFN, ...restFns) => (...args) => restFns.reduce(applyTo, headFN(...args));
const prop = curry( (key, x) => x[key] );
const equals = curry( (x, y) => x === y );
const startsWith = curry( (str, x) => x.indexOf(str) === 0 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment