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

babel-plugin-minify-guarded-expressions

Package Overview
Dependencies
Maintainers
5
Versions
82
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-minify-guarded-expressions - npm Package Compare versions

Comparing version 0.3.0-alpha.670b24ec to 0.3.0-alpha.6ae655c0

26

lib/index.js
"use strict";
module.exports = function (_ref) {
var t = _ref.types;
module.exports = function ({ types: t }) {
const flipExpressions = require("babel-helper-flip-expressions")(t);
var flipExpressions = require("babel-helper-flip-expressions")(t);
return {

@@ -17,7 +15,7 @@ name: "minify-guarded-expressions",

enter: [function (path) {
var node = path.node;
const node = path.node;
var left = path.get("left");
var right = path.get("right");
const left = path.get("left");
const right = path.get("right");

@@ -31,6 +29,6 @@ // issues - 171, 174, 176

// we can safely replace the entire expression
var shouldBail = !path.parentPath.isExpressionStatement();
const shouldBail = !path.parentPath.isExpressionStatement();
if (node.operator === "&&") {
var leftTruthy = left.evaluateTruthy();
const leftTruthy = left.evaluateTruthy();
if (leftTruthy === false) {

@@ -45,6 +43,6 @@ // Short-circuit

} else if (node.operator === "||") {
var _leftTruthy = left.evaluateTruthy();
if (_leftTruthy === false && left.isPure()) {
const leftTruthy = left.evaluateTruthy();
if (leftTruthy === false && left.isPure()) {
path.replaceWith(node.right);
} else if (_leftTruthy === true) {
} else if (leftTruthy === true) {
// Short-circuit

@@ -57,3 +55,3 @@ path.replaceWith(node.left);

}, function (path) {
var node = path.node;
const node = path.node;

@@ -72,3 +70,3 @@

if (flipExpressions.shouldFlip(node, 1)) {
var newNode = flipExpressions.flip(node, true);
const newNode = flipExpressions.flip(node, true);
path.replaceWith(newNode);

@@ -75,0 +73,0 @@ }

{
"name": "babel-plugin-minify-guarded-expressions",
"version": "0.3.0-alpha.670b24ec",
"version": "0.3.0-alpha.6ae655c0",
"description": "",

@@ -15,4 +15,4 @@ "keywords": [

"dependencies": {
"babel-helper-flip-expressions": "^0.3.0-alpha.670b24ec"
"babel-helper-flip-expressions": "^0.3.0-alpha.6ae655c0"
}
}
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