Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
@babel/plugin-transform-logical-assignment-operators
Advanced tools
Transforms logical assignment operators into short-circuited assignments
The @babel/plugin-transform-logical-assignment-operators package is a Babel plugin that allows the transformation of logical assignment operators in JavaScript code. This plugin is particularly useful for ensuring compatibility with environments that do not support newer ECMAScript features, such as logical assignment operators. It transforms these operators into equivalent expressions that are compatible with older JavaScript engines.
Logical AND assignment (&&=)
This feature allows the use of the logical AND assignment operator, which assigns the value on the right to the variable on the left only if the left side is truthy.
a &&= b; // Transforms to: a = a && b;
Logical OR assignment (||=)
This feature enables the logical OR assignment operator, which assigns the value on the right to the variable on the left if the left side is falsy.
a ||= b; // Transforms to: a = a || b;
Logical nullish assignment (??=)
This feature supports the logical nullish assignment operator, which assigns the value on the right to the variable on the left only if the left side is null or undefined.
a ??= b; // Transforms to: a = a ?? b;
This package transforms optional chaining operators (?.) into a series of checks that ensure each reference is valid before accessing deeper properties. It is similar in that it also deals with modern JavaScript features for compatibility but focuses on property access rather than assignment.
This package transforms nullish coalescing operators (??) into equivalent logical expressions. It is similar to @babel/plugin-transform-logical-assignment-operators in handling operations that involve null or undefined values but focuses on binary operations rather than assignments.
Transforms logical assignment operators into short-circuited assignments
See our website @babel/plugin-transform-logical-assignment-operators for more information.
Using npm:
npm install --save-dev @babel/plugin-transform-logical-assignment-operators
or using yarn:
yarn add @babel/plugin-transform-logical-assignment-operators --dev
v7.25.8 (2024-10-10)
babel-core
resolvePlugin
/resolvePreset
(@nicolo-ribaudo)babel-parser
, babel-plugin-proposal-async-do-expressions
, babel-plugin-proposal-destructuring-private
, babel-plugin-proposal-do-expressions
, babel-plugin-proposal-explicit-resource-management
, babel-plugin-proposal-export-default-from
, babel-plugin-proposal-function-bind
, babel-plugin-proposal-function-sent
, babel-plugin-proposal-import-defer
, babel-plugin-proposal-partial-application
, babel-plugin-proposal-throw-expressions
, babel-plugin-transform-async-generator-functions
, babel-plugin-transform-class-static-block
, babel-plugin-transform-dynamic-import
, babel-plugin-transform-export-namespace-from
, babel-plugin-transform-json-strings
, babel-plugin-transform-logical-assignment-operators
, babel-plugin-transform-nullish-coalescing-operator
, babel-plugin-transform-numeric-separator
, babel-plugin-transform-object-rest-spread
, babel-plugin-transform-optional-catch-binding
, babel-plugin-transform-optional-chaining
, babel-plugin-transform-private-property-in-object
, babel-preset-env
FAQs
Transforms logical assignment operators into short-circuited assignments
The npm package @babel/plugin-transform-logical-assignment-operators receives a total of 11,188,240 weekly downloads. As such, @babel/plugin-transform-logical-assignment-operators popularity was classified as popular.
We found that @babel/plugin-transform-logical-assignment-operators demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.