aboutsummaryrefslogtreecommitdiff
path: root/lib/compress.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2021-01-19 23:27:32 +0000
committerGitHub <noreply@github.com>2021-01-20 07:27:32 +0800
commitd37ee4d41c70aa309550e7337f75126ef2932c62 (patch)
treef92d069caa23a7bb6824014a6139b68c8596811c /lib/compress.js
parent7793c6c389930dd10fdce5a12b24c95d5bb93933 (diff)
downloadtracifyjs-d37ee4d41c70aa309550e7337f75126ef2932c62.tar.gz
tracifyjs-d37ee4d41c70aa309550e7337f75126ef2932c62.zip
support asynchronous test cases properly (#4529)
Diffstat (limited to 'lib/compress.js')
-rw-r--r--lib/compress.js9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 21072f0c..4710b69f 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -382,6 +382,7 @@ merge(Compressor.prototype, {
});
}
+ var RE_POSITIVE_INTEGER = /^(0|[1-9][0-9]*)$/;
(function(def) {
def(AST_Node, noop);
@@ -603,7 +604,7 @@ merge(Compressor.prototype, {
if (!is_arguments(def)) return;
var key = node.property;
if (key.is_constant()) key = key.value;
- if (!(key instanceof AST_Node) && !/^[1-9]*[0-9]$/.test(key)) return;
+ if (!(key instanceof AST_Node) && !RE_POSITIVE_INTEGER.test(key)) return;
def.reassigned = true;
(key instanceof AST_Node ? def.scope.argnames : [ def.scope.argnames[key] ]).forEach(function(argname) {
if (argname instanceof AST_SymbolFunarg) argname.definition().fixed = false;
@@ -8160,7 +8161,7 @@ merge(Compressor.prototype, {
try {
var code = "n(function(" + self.args.slice(0, -1).map(function(arg) {
return arg.value;
- }).join(",") + "){" + self.args[self.args.length - 1].value + "})";
+ }).join() + "){" + self.args[self.args.length - 1].value + "})";
var ast = parse(code);
var mangle = { ie8: compressor.option("ie8") };
ast.figure_out_scope(mangle);
@@ -8183,7 +8184,7 @@ merge(Compressor.prototype, {
make_node(AST_String, self, {
value: fun.argnames.map(function(arg) {
return arg.print_to_string();
- }).join(",")
+ }).join(),
}),
make_node(AST_String, self.args[self.args.length - 1], {
value: code.get().replace(/^\{|\}$/g, "")
@@ -10846,7 +10847,7 @@ merge(Compressor.prototype, {
flush();
values.push(prop);
}
- if (found && !generated && typeof key == "string" && /^[1-9]*[0-9]$/.test(key)) {
+ if (found && !generated && typeof key == "string" && RE_POSITIVE_INTEGER.test(key)) {
generated = true;
if (keys.has(key)) prop = keys.get(key)[0];
prop.key = make_node(AST_Number, prop, {