Sha256: dafd6f6a3b3c42ef5abae8f9db9e2cd0db8959ce0c7d6f4b7b5ff331ffd3655d

Contents?: true

Size: 1.44 KB

Versions: 3

Compression:

Stored size: 1.44 KB

Contents

"use strict";

exports.__esModule = true;
exports.UnaryExpression = UnaryExpression;
exports.BinaryExpression = BinaryExpression;
exports.VariableDeclaration = VariableDeclaration;

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }

var _types = require("../../../types");

var t = _interopRequireWildcard(_types);

var metadata = {
  optional: true
};

exports.metadata = metadata;

function UnaryExpression(node, parent, scope, file) {
  if (node._ignoreSpecSymbols) return;

  if (node.operator === "typeof") {
    var call = t.callExpression(file.addHelper("typeof"), [node.argument]);
    if (this.get("argument").isIdentifier()) {
      var undefLiteral = t.literal("undefined");
      var unary = t.unaryExpression("typeof", node.argument);
      unary._ignoreSpecSymbols = true;
      return t.conditionalExpression(t.binaryExpression("===", unary, undefLiteral), undefLiteral, call);
    } else {
      return call;
    }
  }
}

function BinaryExpression(node, parent, scope, file) {
  if (node.operator === "instanceof") {
    return t.callExpression(file.addHelper("instanceof"), [node.left, node.right]);
  }
}

function VariableDeclaration(node) {
  if (node._generated) this.skip();
}

exports.FunctionDeclaration = VariableDeclaration;

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gulp_assets-1.0.0.pre.5 template/node_modules/babel-core/lib/babel/transformation/transformers/es6/spec.symbols.js
gulp_assets-1.0.0.pre.4 template/node_modules/babel-core/lib/babel/transformation/transformers/es6/spec.symbols.js
gulp_assets-1.0.0.pre.3 template/node_modules/babel-core/lib/babel/transformation/transformers/es6/spec.symbols.js