index.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. /*istanbul ignore next*/"use strict";
  2. exports.__esModule = true;
  3. exports.default = function ( /*istanbul ignore next*/_ref) {
  4. /*istanbul ignore next*/var t = _ref.types;
  5. return {
  6. visitor: { /*istanbul ignore next*/
  7. ArrowFunctionExpression: function ArrowFunctionExpression(path, state) {
  8. if (state.opts.spec) {
  9. /*istanbul ignore next*/var node = path.node;
  10. if (node.shadow) return;
  11. node.shadow = { this: false };
  12. node.type = "FunctionExpression";
  13. var boundThis = t.thisExpression();
  14. boundThis._forceShadow = path;
  15. // make sure that arrow function won't be instantiated
  16. path.ensureBlock();
  17. path.get("body").unshiftContainer("body", t.expressionStatement(t.callExpression(state.addHelper("newArrowCheck"), [t.thisExpression(), boundThis])));
  18. path.replaceWith(t.callExpression(t.memberExpression(node, t.identifier("bind")), [t.thisExpression()]));
  19. } else {
  20. path.arrowFunctionToShadowed();
  21. }
  22. }
  23. }
  24. };
  25. };
  26. /*istanbul ignore next*/module.exports = exports["default"];