![Namecheap Takes Down Polyfill.io Service Following Supply Chain Attack](https://cdn.sanity.io/images/cgdhsj6q/production/6af25114feaaac7179b18127c83327568ff592d1-1024x1024.webp?w=800&fit=max&auto=format)
Security News
Namecheap Takes Down Polyfill.io Service Following Supply Chain Attack
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
@babel/plugin-proposal-logical-assignment-operators
Advanced tools
Package description
The @babel/plugin-proposal-logical-assignment-operators package allows Babel to compile logical assignment operators into ES5 or your target environment's JavaScript. Logical assignment operators combine logical operations with assignment expressions, enabling more concise and expressive code.
Logical AND assignment (&&=)
This feature allows the assignment of the right operand to the left operand only if the left operand is truthy. It's equivalent to `a = a && b;`.
a &&= b;
Logical OR assignment (||=)
This feature enables the assignment of the right operand to the left operand if the left operand is falsy. It simplifies the expression `a = a || b;`.
a ||= b;
Logical nullish assignment (??=)
This feature assigns the right operand to the left operand only if the left operand is null or undefined, making the code `a = a ?? b;` more concise.
a ??= b;
Similar in its proposal nature and goal to enhance JavaScript's expressiveness, this package allows for optional chaining (`?.`) in JavaScript, enabling reading the value of a property located deep within a chain of connected objects without having to expressly validate each reference in the chain.
This package introduces the nullish coalescing operator (`??`), which is closely related to the logical nullish assignment operator provided by @babel/plugin-proposal-logical-assignment-operators. It allows developers to provide a default value for potentially null or undefined expressions.
Readme
Transforms logical assignment operators into short-circuited assignments
In
a ||= b;
obj.a.b ||= c;
a &&= b;
obj.a.b &&= c;
Out
var _obj$a, _obj$a2;
a || (a = b);
(_obj$a = obj.a).b || (_obj$a.b = c);
a && (a = b);
(_obj$a2 = obj.a).b && (_obj$a2.b = c);
npm install --save-dev @babel/plugin-proposal-logical-assignment-operators
.babelrc
(Recommended).babelrc
{
"plugins": ["@babel/plugin-proposal-logical-assignment-operators"]
}
babel --plugins @babel/plugin-proposal-logical-assignment-operators script.js
require("@babel/core").transform("code", {
plugins: ["@babel/plugin-proposal-logical-assignment-operators"]
});
FAQs
Transforms logical assignment operators into short-circuited assignments
The npm package @babel/plugin-proposal-logical-assignment-operators receives a total of 5,918,438 weekly downloads. As such, @babel/plugin-proposal-logical-assignment-operators popularity was classified as popular.
We found that @babel/plugin-proposal-logical-assignment-operators demonstrated a not healthy version release cadence and project activity because the last version was released 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.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.
Security News
A JavaScript library maintainer is under fire after merging a controversial PR to support legacy versions of Node.js.