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

@babel/plugin-proposal-optional-chaining

Package Overview
Dependencies
Maintainers
6
Versions
70
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@babel/plugin-proposal-optional-chaining - npm Package Compare versions

Comparing version 7.10.1 to 7.10.3

38

lib/index.js

@@ -32,10 +32,17 @@ "use strict";

const {
parentPath,
scope
} = path;
let maybeParenthesized = path;
const parentPath = path.findParent(p => {
if (!p.isParenthesizedExpression()) return true;
maybeParenthesized = p;
});
let isDeleteOperation = false;
const parentIsCall = parentPath.isCallExpression({
callee: maybeParenthesized.node
}) && path.isOptionalMemberExpression();
const optionals = [];
let optionalPath = path;
while (optionalPath.isOptionalMemberExpression() || optionalPath.isOptionalCallExpression()) {
while (optionalPath.isOptionalMemberExpression() || optionalPath.isOptionalCallExpression() || optionalPath.isParenthesizedExpression() || optionalPath.isTSNonNullExpression()) {
const {

@@ -55,5 +62,3 @@ node

optionalPath = optionalPath.get("callee");
}
if (optionalPath.isTSNonNullExpression()) {
} else {
optionalPath = optionalPath.get("expression");

@@ -117,3 +122,24 @@ }

replacementPath.replaceWith(_core.types.conditionalExpression(loose ? _core.types.binaryExpression("==", _core.types.cloneNode(check), _core.types.nullLiteral()) : _core.types.logicalExpression("||", _core.types.binaryExpression("===", _core.types.cloneNode(check), _core.types.nullLiteral()), _core.types.binaryExpression("===", _core.types.cloneNode(ref), scope.buildUndefinedNode())), isDeleteOperation ? _core.types.booleanLiteral(true) : scope.buildUndefinedNode(), replacementPath.node));
let replacement = replacementPath.node;
if (i === 0 && parentIsCall) {
var _baseRef;
const {
object
} = replacement;
let baseRef;
if (!loose || !isSimpleMemberExpression(object)) {
baseRef = scope.maybeGenerateMemoised(object);
if (baseRef) {
replacement.object = _core.types.assignmentExpression("=", baseRef, object);
}
}
replacement = _core.types.callExpression(_core.types.memberExpression(replacement, _core.types.identifier("bind")), [_core.types.cloneNode((_baseRef = baseRef) != null ? _baseRef : object)]);
}
replacementPath.replaceWith(_core.types.conditionalExpression(loose ? _core.types.binaryExpression("==", _core.types.cloneNode(check), _core.types.nullLiteral()) : _core.types.logicalExpression("||", _core.types.binaryExpression("===", _core.types.cloneNode(check), _core.types.nullLiteral()), _core.types.binaryExpression("===", _core.types.cloneNode(ref), scope.buildUndefinedNode())), isDeleteOperation ? _core.types.booleanLiteral(true) : scope.buildUndefinedNode(), replacement));
replacementPath = replacementPath.get("alternate");

@@ -120,0 +146,0 @@ }

10

package.json
{
"name": "@babel/plugin-proposal-optional-chaining",
"version": "7.10.1",
"version": "7.10.3",
"description": "Transform optional chaining operators into a series of nil checks",

@@ -19,3 +19,3 @@ "repository": {

"dependencies": {
"@babel/helper-plugin-utils": "^7.10.1",
"@babel/helper-plugin-utils": "^7.10.3",
"@babel/plugin-syntax-optional-chaining": "^7.8.0"

@@ -27,7 +27,7 @@ },

"devDependencies": {
"@babel/core": "^7.10.1",
"@babel/helper-plugin-test-runner": "^7.10.1",
"@babel/core": "^7.10.3",
"@babel/helper-plugin-test-runner": "^7.10.3",
"@babel/plugin-transform-block-scoping": "^7.10.1"
},
"gitHead": "88f57a7ea659d25232bf62de1efceb5d6299b8cf"
"gitHead": "2787ee2f967b6d8e1121fca00a8d578d75449a53"
}
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