Socket
Socket
Sign inDemoInstall

@babel/plugin-transform-optional-chaining

Package Overview
Dependencies
Maintainers
4
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

Comparing version 7.22.10 to 7.22.11

11

lib/index.js

@@ -6,3 +6,2 @@ 'use strict';

var helperPluginUtils = require('@babel/helper-plugin-utils');
var syntaxOptionalChaining = require('@babel/plugin-syntax-optional-chaining');
var core = require('@babel/core');

@@ -173,6 +172,10 @@ var helperSkipTransparentExpressionWrappers = require('@babel/helper-skip-transparent-expression-wrappers');

const ifNullishFalse = ifNullishBoolean && ifNullish.value === false;
const ifNullishVoid = !ifNullishBoolean && core.types.isUnaryExpression(ifNullish, {
operator: "void"
});
const isEvaluationValueIgnored = (core.types.isExpressionStatement(replacementPath.parent) || core.types.isSequenceExpression(replacementPath.parent)) && !replacementPath.isCompletionRecord();
const tpl = ifNullishFalse ? noDocumentAll ? NULLISH_CHECK_NO_DDA_NEG : NULLISH_CHECK_NEG : noDocumentAll ? NULLISH_CHECK_NO_DDA : NULLISH_CHECK;
const logicalOp = ifNullishFalse ? "&&" : "||";
const check = checks.map(tpl).reduce((expr, check) => core.types.logicalExpression(logicalOp, expr, check));
replacementPath.replaceWith(ifNullishBoolean ? core.types.logicalExpression(logicalOp, check, result) : core.types.conditionalExpression(check, ifNullish, result));
replacementPath.replaceWith(ifNullishBoolean || ifNullishVoid && isEvaluationValueIgnored ? core.types.logicalExpression(logicalOp, check, result) : core.types.conditionalExpression(check, ifNullish, result));
}

@@ -223,3 +226,3 @@ function transform(path, assumptions) {

name: "transform-optional-chaining",
inherits: syntaxOptionalChaining.default,
inherits: require("@babel/plugin-syntax-optional-chaining").default,
visitor: {

@@ -236,4 +239,4 @@ "OptionalCallExpression|OptionalMemberExpression"(path) {

exports["default"] = index;
exports.default = index;
exports.transform = transform;
//# sourceMappingURL=index.js.map
{
"name": "@babel/plugin-transform-optional-chaining",
"version": "7.22.10",
"version": "7.22.11",
"description": "Transform optional chaining operators into a series of nil checks",

@@ -28,6 +28,6 @@ "repository": {

"devDependencies": {
"@babel/core": "^7.22.10",
"@babel/core": "^7.22.11",
"@babel/helper-plugin-test-runner": "^7.22.5",
"@babel/plugin-transform-block-scoping": "^7.22.10",
"@babel/traverse": "^7.22.10"
"@babel/traverse": "^7.22.11"
},

@@ -34,0 +34,0 @@ "engines": {

Sorry, the diff of this file is not supported yet

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