Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@babel/plugin-transform-typeof-symbol

Package Overview
Dependencies
Maintainers
6
Versions
79
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@babel/plugin-transform-typeof-symbol - npm Package Compare versions

Comparing version 7.0.0-beta.43 to 7.0.0-beta.44

38

lib/index.js

@@ -9,5 +9,5 @@ "use strict";

function _helperPluginUtils() {
const data = require("@babel/helper-plugin-utils");
var data = require("@babel/helper-plugin-utils");
_helperPluginUtils = function () {
_helperPluginUtils = function _helperPluginUtils() {
return data;

@@ -20,5 +20,5 @@ };

function _core() {
const data = require("@babel/core");
var data = require("@babel/core");
_core = function () {
_core = function _core() {
return data;

@@ -30,9 +30,9 @@ };

var _default = (0, _helperPluginUtils().declare)(api => {
var _default = (0, _helperPluginUtils().declare)(function (api) {
api.assertVersion(7);
return {
visitor: {
Scope({
scope
}) {
Scope: function Scope(_ref) {
var scope = _ref.scope;
if (!scope.getBinding("Symbol")) {

@@ -44,12 +44,9 @@ return;

},
UnaryExpression(path) {
const {
node,
parent
} = path;
UnaryExpression: function UnaryExpression(path) {
var node = path.node,
parent = path.parent;
if (node.operator !== "typeof") return;
if (path.parentPath.isBinaryExpression() && _core().types.EQUALITY_BINARY_OPERATORS.indexOf(parent.operator) >= 0) {
const opposite = path.getOpposite();
var opposite = path.getOpposite();

@@ -61,4 +58,4 @@ if (opposite.isLiteral() && opposite.node.value !== "symbol" && opposite.node.value !== "object") {

const helper = this.addHelper("typeof");
const isUnderHelper = path.findParent(path => {
var helper = this.addHelper("typeof");
var isUnderHelper = path.findParent(function (path) {
return path.isVariableDeclarator() && path.node.id === helper || path.isFunctionDeclaration() && path.node.id && path.node.id.name === helper.name;

@@ -71,8 +68,8 @@ });

const call = _core().types.callExpression(helper, [node.argument]);
var call = _core().types.callExpression(helper, [node.argument]);
const arg = path.get("argument");
var arg = path.get("argument");
if (arg.isIdentifier() && !path.scope.hasBinding(arg.node.name, true)) {
const unary = _core().types.unaryExpression("typeof", _core().types.cloneNode(node.argument));
var unary = _core().types.unaryExpression("typeof", _core().types.cloneNode(node.argument));

@@ -84,3 +81,2 @@ path.replaceWith(_core().types.conditionalExpression(_core().types.binaryExpression("===", unary, _core().types.stringLiteral("undefined")), _core().types.stringLiteral("undefined"), call));

}
}

@@ -87,0 +83,0 @@ };

{
"name": "@babel/plugin-transform-typeof-symbol",
"version": "7.0.0-beta.43",
"version": "7.0.0-beta.44",
"description": "This transformer wraps all typeof expressions with a method that replicates native behaviour. (ie. returning “symbol” for symbols)",

@@ -12,11 +12,11 @@ "repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-typeof-symbol",

"dependencies": {
"@babel/helper-plugin-utils": "7.0.0-beta.43"
"@babel/helper-plugin-utils": "7.0.0-beta.44"
},
"peerDependencies": {
"@babel/core": "7.0.0-beta.43"
"@babel/core": "7.0.0-beta.44"
},
"devDependencies": {
"@babel/core": "7.0.0-beta.43",
"@babel/helper-plugin-test-runner": "7.0.0-beta.43"
"@babel/core": "7.0.0-beta.44",
"@babel/helper-plugin-test-runner": "7.0.0-beta.44"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc