1
0
mirror of https://github.com/S2-/minifyfromhtml.git synced 2025-08-03 04:10: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

View File

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

View File

@@ -0,0 +1,124 @@
"use strict";
module.exports = function (t) {
return function toMultipleSequenceExpressions(statements) {
const retStatements = [];
let bailed;
do {
const res = convert(statements);
bailed = res.bailed;
const seq = res.seq,
bailedAtIndex = res.bailedAtIndex;
if (seq) {
retStatements.push(t.expressionStatement(seq));
}
if (bailed && statements[bailedAtIndex]) {
retStatements.push(statements[bailedAtIndex]);
}
if (bailed) {
statements = statements.slice(bailedAtIndex + 1);
if (!statements.length) {
bailed = false;
}
}
} while (bailed);
return retStatements;
function convert(nodes) {
const exprs = [];
for (let i = 0; i < nodes.length; i++) {
const bail = () => {
let seq;
if (exprs.length === 1) {
seq = exprs[0];
} else if (exprs.length) {
seq = t.sequenceExpression(exprs);
}
return {
seq,
bailed: true,
bailedAtIndex: i
};
};
const node = nodes[i];
if (t.isExpression(node)) {
exprs.push(node);
} else if (t.isExpressionStatement(node)) {
if (node.expression) exprs.push(node.expression);
} else if (t.isIfStatement(node)) {
let consequent;
if (node.consequent) {
const res = convert([node.consequent]);
if (res.bailed) {
return bail();
}
consequent = res.seq;
}
let alternate;
if (node.alternate) {
const res = convert([node.alternate]);
if (res.bailed) {
return bail();
}
alternate = res.seq;
}
if (!alternate && !consequent) {
exprs.push(node.test);
} else if (!alternate) {
exprs.push(t.logicalExpression("&&", node.test, consequent));
} else if (!consequent) {
exprs.push(t.logicalExpression("||", node.test, alternate));
} else {
exprs.push(t.conditionalExpression(node.test, consequent, alternate));
}
} else if (t.isBlockStatement(node)) {
const res = convert(node.body);
if (res.bailed) {
return bail();
}
if (res.seq) {
exprs.push(res.seq);
}
} else {
return bail();
}
}
let seq;
if (exprs.length === 1) {
seq = exprs[0];
} else if (exprs.length) {
seq = t.sequenceExpression(exprs);
}
/* eslint-disable no-self-assign */
seq = seq;
return {
seq
};
}
};
};

View File

@@ -0,0 +1,46 @@
{
"_from": "babel-helper-to-multiple-sequence-expressions@^0.4.1",
"_id": "babel-helper-to-multiple-sequence-expressions@0.4.1",
"_inBundle": false,
"_integrity": "sha1-FU7MOBGPXBybDp/CNd21OSFJvI8=",
"_location": "/babel-helper-to-multiple-sequence-expressions",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "babel-helper-to-multiple-sequence-expressions@^0.4.1",
"name": "babel-helper-to-multiple-sequence-expressions",
"escapedName": "babel-helper-to-multiple-sequence-expressions",
"rawSpec": "^0.4.1",
"saveSpec": null,
"fetchSpec": "^0.4.1"
},
"_requiredBy": [
"/babel-plugin-minify-simplify"
],
"_resolved": "https://registry.npmjs.org/babel-helper-to-multiple-sequence-expressions/-/babel-helper-to-multiple-sequence-expressions-0.4.1.tgz",
"_shasum": "154ecc38118f5c1c9b0e9fc235ddb5392149bc8f",
"_spec": "babel-helper-to-multiple-sequence-expressions@^0.4.1",
"_where": "/home/s2/Documents/Code/minifyfromhtml/node_modules/babel-plugin-minify-simplify",
"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-to-multiple-sequence-expressions",
"repository": {
"type": "git",
"url": "https://github.com/babel/minify/tree/master/packages/babel-helper-to-multiple-sequence-expressions"
},
"version": "0.4.1"
}