Guest User

Untitled

a guest
Nov 19th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. const curry = fn => (...args) => args.length < fn.length
  2. ? (...rest) => curry(fn)(...args, ...rest)
  3. : fn(...args);
  4.  
  5. const applyTo = curry( (x, fn) => fn(x) );
  6.  
  7. const pipe = (headFN, ...restFns) => (...args) => restFns.reduce(applyTo, headFN(...args));
  8. const prop = curry( (key, x) => x[key] );
  9. const equals = curry( (x, y) => x === y );
  10. const startsWith = curry( (str, x) => x.indexOf(str) === 0 );
Add Comment
Please, Sign In to add comment