722b33ef6496f630aa0ee316fac001cf5cc1b0ecb47ff4b06cc3ec68f8d1b9f2c2c16ec0ee499c7373aa1ab9706af6d2626d6c116739010b783e241702c01f 947 B

123456789101112131415161718192021222324252627
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = replaceShorthandObjectMethod;
  6. var util = require("./util.js");
  7. function replaceShorthandObjectMethod(path) {
  8. const t = util.getTypes();
  9. if (!path.node || !t.isFunction(path.node)) {
  10. throw new Error("replaceShorthandObjectMethod can only be called on Function AST node paths.");
  11. }
  12. if (!t.isObjectMethod(path.node)) {
  13. return path;
  14. }
  15. if (!path.node.generator) {
  16. return path;
  17. }
  18. const parameters = path.node.params.map(function (param) {
  19. return t.cloneDeep(param);
  20. });
  21. const functionExpression = t.functionExpression(null, parameters, t.cloneDeep(path.node.body), path.node.generator, path.node.async);
  22. util.replaceWithOrRemove(path, t.objectProperty(t.cloneDeep(path.node.key), functionExpression, path.node.computed, false));
  23. return path.get("value");
  24. }
  25. //# sourceMappingURL=replaceShorthandObjectMethod.js.map