Socket
Socket
Sign inDemoInstall

@babel/plugin-transform-typeof-symbol

Package Overview
Dependencies
Maintainers
5
Versions
76
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.46 to 7.0.0-beta.47

32

lib/index.js

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

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

@@ -20,3 +20,3 @@ _helperPluginUtils = function _helperPluginUtils() {

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

@@ -30,9 +30,9 @@ _core = function _core() {

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

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

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

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

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

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

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

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

}
}

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

{
"name": "@babel/plugin-transform-typeof-symbol",
"version": "7.0.0-beta.46",
"version": "7.0.0-beta.47",
"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.46"
"@babel/helper-plugin-utils": "7.0.0-beta.47"
},
"peerDependencies": {
"@babel/core": "7.0.0-beta.46"
"@babel/core": "7.0.0-beta.47"
},
"devDependencies": {
"@babel/core": "7.0.0-beta.46",
"@babel/helper-plugin-test-runner": "7.0.0-beta.46"
"@babel/core": "7.0.0-beta.47",
"@babel/helper-plugin-test-runner": "7.0.0-beta.47"
}
}
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