web 3d图形渲染器
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.4 KiB

  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. Object.defineProperty(exports, "convertFunctionParams", {
  6. enumerable: true,
  7. get: function () {
  8. return _params.default;
  9. }
  10. });
  11. exports.default = void 0;
  12. var _helperPluginUtils = require("@babel/helper-plugin-utils");
  13. var _params = _interopRequireDefault(require("./params"));
  14. var _rest = _interopRequireDefault(require("./rest"));
  15. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  16. var _default = (0, _helperPluginUtils.declare)((api, options) => {
  17. var _api$assumption;
  18. api.assertVersion(7);
  19. const ignoreFunctionLength = (_api$assumption = api.assumption("ignoreFunctionLength")) != null ? _api$assumption : options.loose;
  20. const noNewArrows = api.assumption("noNewArrows");
  21. return {
  22. name: "transform-parameters",
  23. visitor: {
  24. Function(path) {
  25. if (path.isArrowFunctionExpression() && path.get("params").some(param => param.isRestElement() || param.isAssignmentPattern())) {
  26. path.arrowFunctionToExpression({
  27. noNewArrows
  28. });
  29. }
  30. const convertedRest = (0, _rest.default)(path);
  31. const convertedParams = (0, _params.default)(path, ignoreFunctionLength);
  32. if (convertedRest || convertedParams) {
  33. path.scope.crawl();
  34. }
  35. }
  36. }
  37. };
  38. });
  39. exports.default = _default;