rewrite-this.js 711 B

12345678910111213141516171819202122232425
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = rewriteThis;
  6. var _helperEnvironmentVisitor = require("@babel/helper-environment-visitor");
  7. var _traverse = require("@babel/traverse");
  8. var _t = require("@babel/types");
  9. const {
  10. numericLiteral,
  11. unaryExpression
  12. } = _t;
  13. const rewriteThisVisitor = _traverse.default.visitors.merge([_helperEnvironmentVisitor.default, {
  14. ThisExpression(path) {
  15. path.replaceWith(unaryExpression("void", numericLiteral(0), true));
  16. }
  17. }]);
  18. function rewriteThis(programPath) {
  19. (0, _traverse.default)(programPath.node, Object.assign({}, rewriteThisVisitor, {
  20. noScope: true
  21. }));
  22. }
  23. //# sourceMappingURL=rewrite-this.js.map