_curry.js 750 B

123456789101112131415161718192021222324
  1. "use strict";
  2. exports.__esModule = true;
  3. exports["default"] = curry;
  4. // Type definitions taken from https://github.com/gcanti/flow-static-land/blob/master/src/Fun.js
  5. // eslint-disable-next-line no-unused-vars
  6. // eslint-disable-next-line no-unused-vars
  7. // eslint-disable-next-line no-redeclare
  8. function curried(f, length, acc) {
  9. return function fn() {
  10. // eslint-disable-next-line prefer-rest-params
  11. var combined = acc.concat(Array.prototype.slice.call(arguments));
  12. return combined.length >= length ? f.apply(this, combined) : curried(f, length, combined);
  13. };
  14. } // eslint-disable-next-line no-redeclare
  15. function curry(f) {
  16. // eslint-disable-line no-redeclare
  17. return curried(f, f.length, []);
  18. }
  19. module.exports = exports.default;