UNPKG

babel-core

Version:

Turn ES6 code into readable vanilla ES5 with source maps

25 lines (18 loc) 755 B
"use strict"; var _interopRequireWildcard = function (obj) { return obj && obj.__esModule ? obj : { "default": obj }; }; exports.UnaryExpression = UnaryExpression; var t = _interopRequireWildcard(require("../../../types")); var optional = exports.optional = true; function UnaryExpression(node, parent, scope, file) { this.skip(); if (node.operator === "typeof") { var call = t.callExpression(file.addHelper("typeof"), [node.argument]); if (t.isIdentifier(node.argument)) { var undefLiteral = t.literal("undefined"); return t.conditionalExpression(t.binaryExpression("===", t.unaryExpression("typeof", node.argument), undefLiteral), undefLiteral, call); } else { return call; } } } exports.__esModule = true;