curry.js 298 B

12345678910111213
  1. const curry = fn => {
  2. return function curried (...args) {
  3. const that = this;
  4. if (args.length < fn.length) {
  5. return curried.bind.apply(curried, [that].concat(args));
  6. } else {
  7. return fn.apply(that, args);
  8. }
  9. };
  10. };
  11. export default curry;