minor clean-ups (#5282)
This commit is contained in:
@@ -116,9 +116,7 @@ function Compressor(options, false_by_default) {
|
|||||||
var global_defs = this.options["global_defs"];
|
var global_defs = this.options["global_defs"];
|
||||||
if (typeof global_defs == "object") for (var key in global_defs) {
|
if (typeof global_defs == "object") for (var key in global_defs) {
|
||||||
if (/^@/.test(key) && HOP(global_defs, key)) {
|
if (/^@/.test(key) && HOP(global_defs, key)) {
|
||||||
global_defs[key.slice(1)] = parse(global_defs[key], {
|
global_defs[key.slice(1)] = parse(global_defs[key], { expression: true });
|
||||||
expression: true
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.options["inline"] === true) this.options["inline"] = 4;
|
if (this.options["inline"] === true) this.options["inline"] = 4;
|
||||||
@@ -4917,7 +4915,7 @@ Compressor.prototype.compress = function(node) {
|
|||||||
return result;
|
return result;
|
||||||
|
|
||||||
function decimals(operand) {
|
function decimals(operand) {
|
||||||
var match = /(\.[0-9]*)?(e.+)?$/.exec(+operand);
|
var match = /(\.[0-9]*)?(e[^e]+)?$/.exec(+operand);
|
||||||
return (match[1] || ".").length - 1 - (match[2] || "").slice(1);
|
return (match[1] || ".").length - 1 - (match[2] || "").slice(1);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -7862,7 +7860,7 @@ Compressor.prototype.compress = function(node) {
|
|||||||
s = s.parent_scope;
|
s = s.parent_scope;
|
||||||
} while (s && s !== this);
|
} while (s && s !== this);
|
||||||
});
|
});
|
||||||
prefix = prefix.replace(/(?:^[^a-z_$]|[^a-z0-9_$])/ig, "_");
|
prefix = prefix.replace(/^[^a-z_$]|[^a-z0-9_$]/gi, "_");
|
||||||
var name = prefix;
|
var name = prefix;
|
||||||
for (var i = 0; !all(scopes, function(scope) {
|
for (var i = 0; !all(scopes, function(scope) {
|
||||||
return !scope.var_names().has(name);
|
return !scope.var_names().has(name);
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ function read_source_map(name, toplevel) {
|
|||||||
var match = /^# ([^\s=]+)=(\S+)\s*$/.exec(comment.value);
|
var match = /^# ([^\s=]+)=(\S+)\s*$/.exec(comment.value);
|
||||||
if (!match) break;
|
if (!match) break;
|
||||||
if (match[1] == "sourceMappingURL") {
|
if (match[1] == "sourceMappingURL") {
|
||||||
match = /^data:application\/json(;.*?)?;base64,(\S+)$/.exec(match[2]);
|
match = /^data:application\/json(;.*?)?;base64,([^,]+)$/.exec(match[2]);
|
||||||
if (!match) break;
|
if (!match) break;
|
||||||
return to_ascii(match[2]);
|
return to_ascii(match[2]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1005,7 +1005,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
def_to_moz(AST_RegExp, function To_Moz_RegExpLiteral(M) {
|
def_to_moz(AST_RegExp, function To_Moz_RegExpLiteral(M) {
|
||||||
var flags = M.value.toString().match(/[gimuy]*$/)[0];
|
var flags = M.value.toString().match(/\/([gimuy]*)$/)[1];
|
||||||
var value = "/" + M.value.raw_source + "/" + flags;
|
var value = "/" + M.value.raw_source + "/" + flags;
|
||||||
return {
|
return {
|
||||||
type: "Literal",
|
type: "Literal",
|
||||||
@@ -1013,8 +1013,8 @@
|
|||||||
raw: value,
|
raw: value,
|
||||||
regex: {
|
regex: {
|
||||||
pattern: M.value.raw_source,
|
pattern: M.value.raw_source,
|
||||||
flags: flags
|
flags: flags,
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -521,9 +521,7 @@ function OutputStream(options) {
|
|||||||
indent();
|
indent();
|
||||||
}
|
}
|
||||||
var preamble = options.preamble;
|
var preamble = options.preamble;
|
||||||
if (preamble) {
|
if (preamble) print(preamble.replace(/\r\n?|\u2028|\u2029|(^|\S)\s*$/g, "$1\n"));
|
||||||
print(preamble.replace(/\r\n?|[\n\u2028\u2029]|\s*$/g, "\n"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
comments = comments.filter(comment_filter, node);
|
comments = comments.filter(comment_filter, node);
|
||||||
@@ -1870,8 +1868,8 @@ function OutputStream(options) {
|
|||||||
len = match[0].length;
|
len = match[0].length;
|
||||||
digits = str.slice(len);
|
digits = str.slice(len);
|
||||||
candidates.push(digits + "e-" + (digits.length + len - 1));
|
candidates.push(digits + "e-" + (digits.length + len - 1));
|
||||||
} else if (match = /0+$/.exec(str)) {
|
} else if (match = /[^0]0+$/.exec(str)) {
|
||||||
len = match[0].length;
|
len = match[0].length - 1;
|
||||||
candidates.push(str.slice(0, -len) + "e" + len);
|
candidates.push(str.slice(0, -len) + "e" + len);
|
||||||
} else if (match = /^(\d)\.(\d+)e(-?\d+)$/.exec(str)) {
|
} else if (match = /^(\d)\.(\d+)e(-?\d+)$/.exec(str)) {
|
||||||
candidates.push(match[1] + match[2] + "e" + (match[3] - match[2].length));
|
candidates.push(match[1] + match[2] + "e" + (match[3] - match[2].length));
|
||||||
|
|||||||
@@ -11,6 +11,21 @@ async_arrow: {
|
|||||||
node_version: ">=8"
|
node_version: ">=8"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async_computed: {
|
||||||
|
input: {
|
||||||
|
var o = {
|
||||||
|
async [42]() {
|
||||||
|
return this.p;
|
||||||
|
},
|
||||||
|
p: "PASS",
|
||||||
|
};
|
||||||
|
o[42]().then(console.log);
|
||||||
|
}
|
||||||
|
expect_exact: 'var o={async[42](){return this.p},p:"PASS"};o[42]().then(console.log);'
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=8"
|
||||||
|
}
|
||||||
|
|
||||||
async_label: {
|
async_label: {
|
||||||
input: {
|
input: {
|
||||||
(async function() {
|
(async function() {
|
||||||
|
|||||||
@@ -26,9 +26,11 @@ exports.run_code = semver.satisfies(process.version, "0.8") ? function(code, top
|
|||||||
return stdout;
|
return stdout;
|
||||||
} : semver.satisfies(process.version, "<0.12") ? run_code_vm : function(code, toplevel, timeout) {
|
} : semver.satisfies(process.version, "<0.12") ? run_code_vm : function(code, toplevel, timeout) {
|
||||||
if ([
|
if ([
|
||||||
/\basync[ \t]*\([\s\S]*?\)[ \t]*=>/,
|
|
||||||
/\b(async[ \t]+function|Promise|setImmediate|setInterval|setTimeout)\b/,
|
/\b(async[ \t]+function|Promise|setImmediate|setInterval|setTimeout)\b/,
|
||||||
/\basync([ \t]+|[ \t]*#|[ \t]*\*[ \t]*)[^\s()[\]{}#:;,.&|!~=*%/+-]+(\s*\(|[ \t]*=>)/,
|
/\basync([ \t]+|[ \t]*#)[^\s()[\]{}#:;,.&|!~=*%/+-]+(\s*\(|[ \t]*=>)/,
|
||||||
|
/\basync[ \t]*\*[ \t]*[^\s()[\]{}#:;,.&|!~=*%/+-]+\s*\(/,
|
||||||
|
/\basync([ \t]*\*)?[ \t]*\[[\s\S]*?\]\s*\(/,
|
||||||
|
/\basync[ \t]*\([\s\S]*?\)[ \t]*=>/,
|
||||||
].some(function(pattern) {
|
].some(function(pattern) {
|
||||||
return pattern.test(code);
|
return pattern.test(code);
|
||||||
})) {
|
})) {
|
||||||
|
|||||||
@@ -2290,7 +2290,7 @@ function fuzzy_match(original, uglified) {
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
function collect(input, nums) {
|
function collect(input, nums) {
|
||||||
return input.replace(/-?([1-9][0-9]*(\.[0-9]+)?|0\.[0-9]+)(e-?[1-9][0-9]*)?/ig, function(num) {
|
return input.replace(/-?([1-9][0-9]*(\.[0-9]+)?|0\.[0-9]+)(e-?[1-9][0-9]*)?/gi, function(num) {
|
||||||
return "<|" + nums.push(+num) + "|>";
|
return "<|" + nums.push(+num) + "|>";
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user