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.6ae655c0 to 0.3.0-alpha.6ceffb8d

26

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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