diff options
| author | littleblack111 <littleblack11111@gmail.com> | 2026-05-18 23:10:59 +0800 |
|---|---|---|
| committer | littleblack111 <littleblack11111@gmail.com> | 2026-05-18 23:41:44 +0800 |
| commit | fc87c009806dcc98867f6b58efe29b042aa01dee (patch) | |
| tree | 8f59b3f4a5b66e9dfef2d40c8d318e258a521228 /node_modules/babel-plugin-minify-flip-comparisons/lib/index.js | |
| parent | 3336b2356ee6152d9c6ae59bd9b87ccbc0958407 (diff) | |
node: updatemain
Diffstat (limited to 'node_modules/babel-plugin-minify-flip-comparisons/lib/index.js')
| -rw-r--r-- | node_modules/babel-plugin-minify-flip-comparisons/lib/index.js | 61 |
1 files changed, 0 insertions, 61 deletions
diff --git a/node_modules/babel-plugin-minify-flip-comparisons/lib/index.js b/node_modules/babel-plugin-minify-flip-comparisons/lib/index.js deleted file mode 100644 index 47820515..00000000 --- a/node_modules/babel-plugin-minify-flip-comparisons/lib/index.js +++ /dev/null @@ -1,61 +0,0 @@ -"use strict"; - -module.exports = function ({ - types: t -}) { - const isVoid0 = require("babel-helper-is-void-0")(t); - - return { - name: "minify-flip-comparisons", - visitor: { - // flip comparisons with a pure right hand value, this ensures - // consistency with comparisons and increases the length of - // strings that gzip can match - // typeof blah === 'function' -> 'function' === typeof blah - BinaryExpression(path) { - const node = path.node; - const right = node.right, - left = node.left; // Make sure we have a constant on the right. - - if (!t.isLiteral(right) && !isVoid0(right) && !(t.isUnaryExpression(right) && t.isLiteral(right.argument)) && !t.isObjectExpression(right) && !t.isArrayExpression(right)) { - return; - } // Commutative operators. - - - if (t.EQUALITY_BINARY_OPERATORS.indexOf(node.operator) >= 0 || ["*", "^", "&", "|"].indexOf(node.operator) >= 0) { - node.left = right; - node.right = left; - return; - } - - if (t.BOOLEAN_NUMBER_BINARY_OPERATORS.indexOf(node.operator) >= 0) { - node.left = right; - node.right = left; - let operator; - - switch (node.operator) { - case ">": - operator = "<"; - break; - - case "<": - operator = ">"; - break; - - case ">=": - operator = "<="; - break; - - case "<=": - operator = ">="; - break; - } - - node.operator = operator; - return; - } - } - - } - }; -};
\ No newline at end of file |
