Socket
Socket
Sign inDemoInstall

babel-plugin-minify-guarded-expressions

Package Overview
Dependencies
1
Maintainers
5
Versions
82
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.4.0 to 0.4.1

28

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,5 +17,5 @@ name: "minify-guarded-expressions",

enter: [function (path) {
var node = path.node;
var left = path.get("left");
var right = path.get("right"); // issues - 171, 174, 176
const node = path.node;
const left = path.get("left");
const right = path.get("right"); // issues - 171, 174, 176
// we assume that it is returned/assigned/part of a bigger expression

@@ -28,6 +28,6 @@ // or utilized somehow

var shouldBail = !path.parentPath.isExpressionStatement();
const shouldBail = !path.parentPath.isExpressionStatement();
if (node.operator === "&&") {
var leftTruthy = left.evaluateTruthy();
const leftTruthy = left.evaluateTruthy();

@@ -43,7 +43,7 @@ if (leftTruthy === false) {

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

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

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

@@ -70,3 +70,3 @@ if (flipExpressions.hasSeen(node)) {

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

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

{
"name": "babel-plugin-minify-guarded-expressions",
"version": "0.4.0",
"version": "0.4.1",
"description": "",

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

"dependencies": {
"babel-helper-flip-expressions": "^0.4.0"
"babel-helper-flip-expressions": "^0.4.1"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc