aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-12-18 06:55:20 +0000
committerGitHub <noreply@github.com>2020-12-18 14:55:20 +0800
commit9c0718b162e537ee6ad1dd5c7af6fbf5fcb6ae1d (patch)
treea35224e171c0397c095a6bdc41bf106336e22dd0 /lib
parentd2c50ace997da8b1f7a3b0bd75bd1b376907928a (diff)
downloadtracifyjs-9c0718b162e537ee6ad1dd5c7af6fbf5fcb6ae1d.tar.gz
tracifyjs-9c0718b162e537ee6ad1dd5c7af6fbf5fcb6ae1d.zip
enhance `arrows` (#4403)
Diffstat (limited to 'lib')
-rw-r--r--lib/compress.js25
1 files changed, 11 insertions, 14 deletions
diff --git a/lib/compress.js b/lib/compress.js
index ab5ad06d..a3842bed 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -4670,22 +4670,19 @@ merge(Compressor.prototype, {
OPT(AST_Arrow, function(self, compressor) {
if (!compressor.option("arrows")) return self;
- if (self.value) {
- var value = self.value;
- if (is_undefined(value, compressor)) {
- self.value = null;
- } else if (value instanceof AST_UnaryPrefix && value.operator == "void") {
- self.body.push(make_node(AST_SimpleStatement, value, {
- body: value.expression
- }));
- self.value = null;
- }
- } else if (self.body.length == 1) {
- var stat = self.body[0];
- if (stat instanceof AST_Return && stat.value) {
- self.body.pop();
+ var body = tighten_body(self.value ? [ self.first_statement() ] : self.body, compressor);
+ switch (body.length) {
+ case 1:
+ var stat = body[0];
+ if (stat instanceof AST_Return) {
+ self.body.length = 0;
self.value = stat.value;
+ break;
}
+ default:
+ self.body = body;
+ self.value = null;
+ break;
}
return self;
});