summaryrefslogtreecommitdiff
path: root/node_modules/babel-plugin-minify-guarded-expressions
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/babel-plugin-minify-guarded-expressions')
-rw-r--r--node_modules/babel-plugin-minify-guarded-expressions/LICENSE22
-rw-r--r--node_modules/babel-plugin-minify-guarded-expressions/README.md49
-rw-r--r--node_modules/babel-plugin-minify-guarded-expressions/lib/index.js80
-rw-r--r--node_modules/babel-plugin-minify-guarded-expressions/package.json19
4 files changed, 0 insertions, 170 deletions
diff --git a/node_modules/babel-plugin-minify-guarded-expressions/LICENSE b/node_modules/babel-plugin-minify-guarded-expressions/LICENSE
deleted file mode 100644
index f9f0a7f3..00000000
--- a/node_modules/babel-plugin-minify-guarded-expressions/LICENSE
+++ /dev/null
@@ -1,22 +0,0 @@
-Copyright (c) 2015-2016 Amjad Masad <amjad.masad@gmail.com>
-
-MIT License
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/node_modules/babel-plugin-minify-guarded-expressions/README.md b/node_modules/babel-plugin-minify-guarded-expressions/README.md
deleted file mode 100644
index 6927bccc..00000000
--- a/node_modules/babel-plugin-minify-guarded-expressions/README.md
+++ /dev/null
@@ -1,49 +0,0 @@
-# babel-plugin-minify-guarded-expressions
-
-## Example
-
-**In**
-
-```javascript
-!x && foo();
-alert(0 && new Foo());
-```
-
-**Out**
-
-```javascript
-x || foo();
-alert(0);
-```
-
-## Installation
-
-```sh
-npm install babel-plugin-minify-guarded-expressions --save-dev
-```
-
-## Usage
-
-### Via `.babelrc` (Recommended)
-
-**.babelrc**
-
-```json
-{
- "plugins": ["minify-guarded-expressions"]
-}
-```
-
-### Via CLI
-
-```sh
-babel --plugins minify-guarded-expressions script.js
-```
-
-### Via Node API
-
-```javascript
-require("@babel/core").transform("code", {
- plugins: ["minify-guarded-expressions"]
-});
-```
diff --git a/node_modules/babel-plugin-minify-guarded-expressions/lib/index.js b/node_modules/babel-plugin-minify-guarded-expressions/lib/index.js
deleted file mode 100644
index 5cc5f192..00000000
--- a/node_modules/babel-plugin-minify-guarded-expressions/lib/index.js
+++ /dev/null
@@ -1,80 +0,0 @@
-"use strict";
-
-const evaluate = require("babel-helper-evaluate-path");
-
-function evaluateTruthy(path) {
- const res = evaluate(path);
- if (res.confident) return !!res.value;
-}
-
-module.exports = function ({
- types: t
-}) {
- const flipExpressions = require("babel-helper-flip-expressions")(t);
-
- return {
- name: "minify-guarded-expressions",
- visitor: {
- // Convert guarded expressions
- // !a && b() --> a || b();
- // This could change the return result of the expression so we only do it
- // on things where the result is ignored.
- LogicalExpression: {
- enter: [function (path) {
- 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
- // or utilized somehow
- // we check if we shouldBail only when evaluating
- // the rightside of the expression;
- // if the left side is evaluated to be deterministic,
- // we can safely replace the entire expression
-
- const shouldBail = !path.parentPath.isExpressionStatement();
-
- if (node.operator === "&&") {
- const leftTruthy = evaluateTruthy(left);
-
- if (leftTruthy === false) {
- // Short-circuit
- path.replaceWith(node.left);
- } else if (leftTruthy === true && left.isPure()) {
- path.replaceWith(node.right);
- } else if (evaluateTruthy(right) === false && right.isPure() && !shouldBail) {
- path.replaceWith(node.left);
- }
- } else if (node.operator === "||") {
- const leftTruthy = evaluateTruthy(left);
-
- if (leftTruthy === false && left.isPure()) {
- path.replaceWith(node.right);
- } else if (leftTruthy === true) {
- // Short-circuit
- path.replaceWith(node.left);
- } else if (evaluateTruthy(right) === false && right.isPure() && !shouldBail) {
- path.replaceWith(node.left);
- }
- }
- }, function (path) {
- const node = path.node;
-
- if (flipExpressions.hasSeen(node)) {
- return;
- }
-
- if (!path.parentPath.isExpressionStatement() && !(path.parentPath.isSequenceExpression() && path.parentPath.parentPath.isExpressionStatement())) {
- return;
- } // Start counting savings from one since we can ignore the last
- // expression.
-
-
- if (flipExpressions.shouldFlip(node, 1)) {
- const newNode = flipExpressions.flip(node, true);
- path.replaceWith(newNode);
- }
- }]
- }
- }
- };
-}; \ No newline at end of file
diff --git a/node_modules/babel-plugin-minify-guarded-expressions/package.json b/node_modules/babel-plugin-minify-guarded-expressions/package.json
deleted file mode 100644
index aed7a70e..00000000
--- a/node_modules/babel-plugin-minify-guarded-expressions/package.json
+++ /dev/null
@@ -1,19 +0,0 @@
-{
- "name": "babel-plugin-minify-guarded-expressions",
- "version": "0.4.4",
- "description": "",
- "keywords": [
- "babel-plugin"
- ],
- "homepage": "https://github.com/babel/minify#readme",
- "bugs": "https://github.com/babel/minify/issues",
- "license": "MIT",
- "author": "amasad",
- "main": "lib/index.js",
- "repository": "https://github.com/babel/minify/tree/master/packages/babel-plugin-minify-guarded-expressions",
- "dependencies": {
- "babel-helper-evaluate-path": "^0.5.0",
- "babel-helper-flip-expressions": "^0.4.3"
- },
- "gitHead": "e1d0c52f5b501f5849741be6db56f968094854eb"
-}