1
0
mirror of https://github.com/S2-/minifyfromhtml.git synced 2025-08-03 12:20:04 +02:00

add some packages

This commit is contained in:
s2
2018-05-05 13:54:07 +02:00
parent 48c1138518
commit ff6e20677d
3738 changed files with 215920 additions and 0 deletions

7
node_modules/babel-helper-flip-expressions/README.md generated vendored Normal file
View File

@@ -0,0 +1,7 @@
# babel-helper-flip-expressions
## Installation
```sh
npm install babel-helper-flip-expressions
```

109
node_modules/babel-helper-flip-expressions/lib/index.js generated vendored Normal file
View File

@@ -0,0 +1,109 @@
"use strict";
const flipSeen = Symbol("flipSeen");
module.exports = function (t) {
return {
hasSeen(node) {
return !!node[flipSeen];
},
// Takes an expressions and determines if it has
// more nodes that could benifit from flipping than not.
shouldFlip(topNode, savings = 0) {
visit(topNode);
return savings > 0;
function visit(node) {
if (t.isUnaryExpression(node, {
operator: "!"
})) {
savings++;
return;
}
if (t.isLogicalExpression(node)) {
visit(node.left);
visit(node.right);
return;
}
if (!(t.isBinaryExpression(node) && t.EQUALITY_BINARY_OPERATORS.indexOf(node.operator) > -1)) {
// Binary expressions wouldn't hurut because we know how to flip them
savings--;
}
}
},
flip(node, resultNotUsed) {
let lastNodeDesc;
const ret = visit(node);
ret[flipSeen] = true;
if (resultNotUsed && lastNodeDesc) {
const _lastNodeDesc = lastNodeDesc,
parent = _lastNodeDesc.parent,
key = _lastNodeDesc.key;
if (parent && key && t.isUnaryExpression(parent[key], {
operator: "!"
})) {
parent[key] = parent[key].argument;
}
}
return ret;
function visit(node, parent, key) {
lastNodeDesc = {
parent,
key
};
if (t.isUnaryExpression(node, {
operator: "!"
})) {
return node.argument;
}
if (t.isLogicalExpression(node)) {
node.operator = node.operator === "&&" ? "||" : "&&";
node.left = visit(node.left, node, "left");
node.right = visit(node.right, node, "right");
return node;
}
if (t.isBinaryExpression(node)) {
let operator;
switch (node.operator) {
case "!==":
operator = "===";
break;
case "===":
operator = "!==";
break;
case "!=":
operator = "==";
break;
case "==":
operator = "!=";
break;
}
if (operator) {
node.operator = operator;
return node;
} // Falls through to unary expression
}
return t.unaryExpression("!", node, true);
}
}
};
};

View File

@@ -0,0 +1,47 @@
{
"_from": "babel-helper-flip-expressions@^0.4.1",
"_id": "babel-helper-flip-expressions@0.4.1",
"_inBundle": false,
"_integrity": "sha1-zAPYBFjBA7n1BcHGpn++D1nKwyA=",
"_location": "/babel-helper-flip-expressions",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "babel-helper-flip-expressions@^0.4.1",
"name": "babel-helper-flip-expressions",
"escapedName": "babel-helper-flip-expressions",
"rawSpec": "^0.4.1",
"saveSpec": null,
"fetchSpec": "^0.4.1"
},
"_requiredBy": [
"/babel-plugin-minify-guarded-expressions",
"/babel-plugin-minify-simplify"
],
"_resolved": "https://registry.npmjs.org/babel-helper-flip-expressions/-/babel-helper-flip-expressions-0.4.1.tgz",
"_shasum": "cc03d80458c103b9f505c1c6a67fbe0f59cac320",
"_spec": "babel-helper-flip-expressions@^0.4.1",
"_where": "/home/s2/Documents/Code/minifyfromhtml/node_modules/babel-plugin-minify-guarded-expressions",
"author": {
"name": "amasad"
},
"bugs": {
"url": "https://github.com/babel/minify/issues"
},
"bundleDependencies": false,
"deprecated": false,
"description": "## Installation",
"homepage": "https://github.com/babel/minify#readme",
"keywords": [
"babel-plugin"
],
"license": "MIT",
"main": "lib/index.js",
"name": "babel-helper-flip-expressions",
"repository": {
"type": "git",
"url": "https://github.com/babel/minify/tree/master/packages/babel-helper-flip-expressions"
},
"version": "0.4.1"
}