_curry.js 747 B

12345678910111213141516171819202122
  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. }
  15. // eslint-disable-next-line no-redeclare
  16. function curry(f) {
  17. // eslint-disable-line no-redeclare
  18. return curried(f, f.length, []);
  19. }
  20. module.exports = exports.default;