Sha256: cbf5b5f754bb479822f65ae0a5d1956fbfd3b48a52a0dcfd55a56979b8224d6b

Contents?: true

Size: 987 Bytes

Versions: 5

Compression:

Stored size: 987 Bytes

Contents

"use strict";

exports.__esModule = true;

exports["default"] = function (_ref) {
  var t = _ref.types;

  return {
    visitor: {
      ArrowFunctionExpression: function ArrowFunctionExpression(path, state) {
        if (state.opts.spec) {
          var node = path.node;

          if (node.shadow) return;

          node.shadow = { "this": false };
          node.type = "FunctionExpression";

          var boundThis = t.thisExpression();
          boundThis._forceShadow = path;

          // make sure that arrow function won't be instantiated
          path.ensureBlock();
          path.get("body").unshiftContainer("body", t.expressionStatement(t.callExpression(state.addHelper("newArrowCheck"), [t.thisExpression(), boundThis])));

          path.replaceWith(t.callExpression(t.memberExpression(node, t.identifier("bind")), [t.thisExpression()]));
        } else {
          path.arrowFunctionToShadowed();
        }
      }
    }
  };
};

module.exports = exports["default"];

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
babel-schmooze-sprockets-0.1.0 node_modules/babel-plugin-transform-es2015-arrow-functions/lib/index.js
babel-schmooze-sprockets-0.1.0.alpha.3 node_modules/babel-plugin-transform-es2015-arrow-functions/lib/index.js
babel-schmooze-sprockets-0.1.0.alpha.2 node_modules/babel-plugin-transform-es2015-arrow-functions/lib/index.js
es6_tilt-0.1.2 test/dummy/node_modules/babel-plugin-transform-es2015-arrow-functions/lib/index.js
es6_tilt-0.1.1 test/dummy/node_modules/babel-plugin-transform-es2015-arrow-functions/lib/index.js