terser 3.7.6 → 3.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of terser might be problematic. Click here for more details.

package/lib/ast.js CHANGED
@@ -85,7 +85,7 @@ function DEFNODE(type, props, methods, base) {
85
85
  exports["AST_" + type] = ctor;
86
86
  }
87
87
  return ctor;
88
- };
88
+ }
89
89
 
90
90
  var AST_Token = DEFNODE("Token", "type value line col pos endline endcol endpos nlb comments_before comments_after file raw", {
91
91
  }, null);
@@ -148,7 +148,7 @@ var AST_SimpleStatement = DEFNODE("SimpleStatement", "body", {
148
148
  body: "[AST_Node] an expression node (should not be instanceof AST_Statement)"
149
149
  },
150
150
  _walk: function(visitor) {
151
- return visitor._visit(this, function(){
151
+ return visitor._visit(this, function() {
152
152
  this.body._walk(visitor);
153
153
  });
154
154
  }
@@ -162,7 +162,7 @@ function walk_body(node, visitor) {
162
162
  else for (var i = 0, len = body.length; i < len; i++) {
163
163
  body[i]._walk(visitor);
164
164
  }
165
- };
165
+ }
166
166
 
167
167
  function clone_block_scope(deep) {
168
168
  var clone = this._clone(deep);
@@ -181,7 +181,7 @@ var AST_Block = DEFNODE("Block", "body block_scope", {
181
181
  block_scope: "[AST_Scope] the block scope"
182
182
  },
183
183
  _walk: function(visitor) {
184
- return visitor._visit(this, function(){
184
+ return visitor._visit(this, function() {
185
185
  walk_body(this, visitor);
186
186
  });
187
187
  },
@@ -209,7 +209,7 @@ var AST_LabeledStatement = DEFNODE("LabeledStatement", "label", {
209
209
  label: "[AST_Label] a label definition"
210
210
  },
211
211
  _walk: function(visitor) {
212
- return visitor._visit(this, function(){
212
+ return visitor._visit(this, function() {
213
213
  this.label._walk(visitor);
214
214
  this.body._walk(visitor);
215
215
  });
@@ -249,7 +249,7 @@ var AST_DWLoop = DEFNODE("DWLoop", "condition", {
249
249
  var AST_Do = DEFNODE("Do", null, {
250
250
  $documentation: "A `do` statement",
251
251
  _walk: function(visitor) {
252
- return visitor._visit(this, function(){
252
+ return visitor._visit(this, function() {
253
253
  this.body._walk(visitor);
254
254
  this.condition._walk(visitor);
255
255
  });
@@ -259,7 +259,7 @@ var AST_Do = DEFNODE("Do", null, {
259
259
  var AST_While = DEFNODE("While", null, {
260
260
  $documentation: "A `while` statement",
261
261
  _walk: function(visitor) {
262
- return visitor._visit(this, function(){
262
+ return visitor._visit(this, function() {
263
263
  this.condition._walk(visitor);
264
264
  this.body._walk(visitor);
265
265
  });
@@ -274,7 +274,7 @@ var AST_For = DEFNODE("For", "init condition step", {
274
274
  step: "[AST_Node?] the `for` update clause, or null if empty"
275
275
  },
276
276
  _walk: function(visitor) {
277
- return visitor._visit(this, function(){
277
+ return visitor._visit(this, function() {
278
278
  if (this.init) this.init._walk(visitor);
279
279
  if (this.condition) this.condition._walk(visitor);
280
280
  if (this.step) this.step._walk(visitor);
@@ -290,7 +290,7 @@ var AST_ForIn = DEFNODE("ForIn", "init object", {
290
290
  object: "[AST_Node] the object that we're looping through"
291
291
  },
292
292
  _walk: function(visitor) {
293
- return visitor._visit(this, function(){
293
+ return visitor._visit(this, function() {
294
294
  this.init._walk(visitor);
295
295
  this.object._walk(visitor);
296
296
  this.body._walk(visitor);
@@ -298,7 +298,7 @@ var AST_ForIn = DEFNODE("ForIn", "init object", {
298
298
  }
299
299
  }, AST_IterationStatement);
300
300
 
301
- var AST_ForOf = DEFNODE("ForOf", null, {
301
+ var AST_ForOf = DEFNODE("ForOf", "await", {
302
302
  $documentation: "A `for ... of` statement",
303
303
  }, AST_ForIn);
304
304
 
@@ -308,7 +308,7 @@ var AST_With = DEFNODE("With", "expression", {
308
308
  expression: "[AST_Node] the `with` expression"
309
309
  },
310
310
  _walk: function(visitor) {
311
- return visitor._visit(this, function(){
311
+ return visitor._visit(this, function() {
312
312
  this.expression._walk(visitor);
313
313
  this.body._walk(visitor);
314
314
  });
@@ -356,7 +356,7 @@ var AST_Toplevel = DEFNODE("Toplevel", "globals", {
356
356
  var body = this.body;
357
357
  var wrapped_tl = "(function(exports){'$ORIG';})(typeof " + name + "=='undefined'?(" + name + "={}):" + name + ");";
358
358
  wrapped_tl = parse(wrapped_tl);
359
- wrapped_tl = wrapped_tl.transform(new TreeTransformer(function before(node){
359
+ wrapped_tl = wrapped_tl.transform(new TreeTransformer(function(node) {
360
360
  if (node instanceof AST_Directive && node.value == "$ORIG") {
361
361
  return MAP.splice(body);
362
362
  }
@@ -389,7 +389,7 @@ var AST_Expansion = DEFNODE("Expansion", "expression", {
389
389
  },
390
390
  _walk: function(visitor) {
391
391
  var self = this;
392
- return visitor._visit(this, function(){
392
+ return visitor._visit(this, function() {
393
393
  self.expression.walk(visitor);
394
394
  });
395
395
  }
@@ -416,7 +416,7 @@ var AST_Lambda = DEFNODE("Lambda", "name argnames uses_arguments is_generator as
416
416
  return out;
417
417
  },
418
418
  _walk: function(visitor) {
419
- return visitor._visit(this, function(){
419
+ return visitor._visit(this, function() {
420
420
  if (this.name) this.name._walk(visitor);
421
421
  var argnames = this.argnames;
422
422
  for (var i = 0, len = argnames.length; i < len; i++) {
@@ -451,8 +451,8 @@ var AST_Destructuring = DEFNODE("Destructuring", "names is_array", {
451
451
  "is_array": "[Boolean] Whether the destructuring represents an object or array"
452
452
  },
453
453
  _walk: function(visitor) {
454
- return visitor._visit(this, function(){
455
- this.names.forEach(function(name){
454
+ return visitor._visit(this, function() {
455
+ this.names.forEach(function(name) {
456
456
  name._walk(visitor);
457
457
  });
458
458
  });
@@ -489,8 +489,8 @@ var AST_TemplateString = DEFNODE("TemplateString", "segments", {
489
489
  segments: "[AST_Node*] One or more segments, starting with AST_TemplateSegment. AST_Node may follow AST_TemplateSegment, but each AST_Node must be followed by AST_TemplateSegment."
490
490
  },
491
491
  _walk: function(visitor) {
492
- return visitor._visit(this, function(){
493
- this.segments.forEach(function(seg){
492
+ return visitor._visit(this, function() {
493
+ this.segments.forEach(function(seg) {
494
494
  seg._walk(visitor);
495
495
  });
496
496
  });
@@ -517,7 +517,7 @@ var AST_Exit = DEFNODE("Exit", "value", {
517
517
  value: "[AST_Node?] the value returned or thrown by this statement; could be null for AST_Return"
518
518
  },
519
519
  _walk: function(visitor) {
520
- return visitor._visit(this, this.value && function(){
520
+ return visitor._visit(this, this.value && function() {
521
521
  this.value._walk(visitor);
522
522
  });
523
523
  }
@@ -537,7 +537,7 @@ var AST_LoopControl = DEFNODE("LoopControl", "label", {
537
537
  label: "[AST_LabelRef?] the label, or null if none",
538
538
  },
539
539
  _walk: function(visitor) {
540
- return visitor._visit(this, this.label && function(){
540
+ return visitor._visit(this, this.label && function() {
541
541
  this.label._walk(visitor);
542
542
  });
543
543
  }
@@ -560,7 +560,7 @@ var AST_If = DEFNODE("If", "condition alternative", {
560
560
  alternative: "[AST_Statement?] the `else` part, or null if not present"
561
561
  },
562
562
  _walk: function(visitor) {
563
- return visitor._visit(this, function(){
563
+ return visitor._visit(this, function() {
564
564
  this.condition._walk(visitor);
565
565
  this.body._walk(visitor);
566
566
  if (this.alternative) this.alternative._walk(visitor);
@@ -576,7 +576,7 @@ var AST_Switch = DEFNODE("Switch", "expression", {
576
576
  expression: "[AST_Node] the `switch` “discriminant”"
577
577
  },
578
578
  _walk: function(visitor) {
579
- return visitor._visit(this, function(){
579
+ return visitor._visit(this, function() {
580
580
  this.expression._walk(visitor);
581
581
  walk_body(this, visitor);
582
582
  });
@@ -597,7 +597,7 @@ var AST_Case = DEFNODE("Case", "expression", {
597
597
  expression: "[AST_Node] the `case` expression"
598
598
  },
599
599
  _walk: function(visitor) {
600
- return visitor._visit(this, function(){
600
+ return visitor._visit(this, function() {
601
601
  this.expression._walk(visitor);
602
602
  walk_body(this, visitor);
603
603
  });
@@ -613,7 +613,7 @@ var AST_Try = DEFNODE("Try", "bcatch bfinally", {
613
613
  bfinally: "[AST_Finally?] the finally block, or null if not present"
614
614
  },
615
615
  _walk: function(visitor) {
616
- return visitor._visit(this, function(){
616
+ return visitor._visit(this, function() {
617
617
  walk_body(this, visitor);
618
618
  if (this.bcatch) this.bcatch._walk(visitor);
619
619
  if (this.bfinally) this.bfinally._walk(visitor);
@@ -627,7 +627,7 @@ var AST_Catch = DEFNODE("Catch", "argname", {
627
627
  argname: "[AST_SymbolCatch|AST_Destructuring|AST_Expansion|AST_DefaultAssign] symbol for the exception"
628
628
  },
629
629
  _walk: function(visitor) {
630
- return visitor._visit(this, function(){
630
+ return visitor._visit(this, function() {
631
631
  this.argname._walk(visitor);
632
632
  walk_body(this, visitor);
633
633
  });
@@ -646,7 +646,7 @@ var AST_Definitions = DEFNODE("Definitions", "definitions", {
646
646
  definitions: "[AST_VarDef*] array of variable definitions"
647
647
  },
648
648
  _walk: function(visitor) {
649
- return visitor._visit(this, function(){
649
+ return visitor._visit(this, function() {
650
650
  var definitions = this.definitions;
651
651
  for (var i = 0, len = definitions.length; i < len; i++) {
652
652
  definitions[i]._walk(visitor);
@@ -739,7 +739,7 @@ var AST_VarDef = DEFNODE("VarDef", "name value", {
739
739
  value: "[AST_Node?] initializer, or null of there's no initializer"
740
740
  },
741
741
  _walk: function(visitor) {
742
- return visitor._visit(this, function(){
742
+ return visitor._visit(this, function() {
743
743
  this.name._walk(visitor);
744
744
  if (this.value) this.value._walk(visitor);
745
745
  });
@@ -755,7 +755,7 @@ var AST_Call = DEFNODE("Call", "expression args", {
755
755
  args: "[AST_Node*] array of arguments"
756
756
  },
757
757
  _walk: function(visitor) {
758
- return visitor._visit(this, function(){
758
+ return visitor._visit(this, function() {
759
759
  var args = this.args;
760
760
  for (var i = 0, len = args.length; i < len; i++) {
761
761
  args[i]._walk(visitor);
@@ -775,7 +775,7 @@ var AST_Sequence = DEFNODE("Sequence", "expressions", {
775
775
  expressions: "[AST_Node*] array of expressions (at least two)"
776
776
  },
777
777
  _walk: function(visitor) {
778
- return visitor._visit(this, function(){
778
+ return visitor._visit(this, function() {
779
779
  this.expressions.forEach(function(node) {
780
780
  node._walk(visitor);
781
781
  });
@@ -794,7 +794,7 @@ var AST_PropAccess = DEFNODE("PropAccess", "expression property", {
794
794
  var AST_Dot = DEFNODE("Dot", null, {
795
795
  $documentation: "A dotted property access expression",
796
796
  _walk: function(visitor) {
797
- return visitor._visit(this, function(){
797
+ return visitor._visit(this, function() {
798
798
  this.expression._walk(visitor);
799
799
  });
800
800
  }
@@ -803,7 +803,7 @@ var AST_Dot = DEFNODE("Dot", null, {
803
803
  var AST_Sub = DEFNODE("Sub", null, {
804
804
  $documentation: "Index-style property access, i.e. `a[\"foo\"]`",
805
805
  _walk: function(visitor) {
806
- return visitor._visit(this, function(){
806
+ return visitor._visit(this, function() {
807
807
  this.expression._walk(visitor);
808
808
  this.property._walk(visitor);
809
809
  });
@@ -817,7 +817,7 @@ var AST_Unary = DEFNODE("Unary", "operator expression", {
817
817
  expression: "[AST_Node] expression that this unary operator applies to"
818
818
  },
819
819
  _walk: function(visitor) {
820
- return visitor._visit(this, function(){
820
+ return visitor._visit(this, function() {
821
821
  this.expression._walk(visitor);
822
822
  });
823
823
  }
@@ -839,7 +839,7 @@ var AST_Binary = DEFNODE("Binary", "operator left right", {
839
839
  right: "[AST_Node] right-hand side expression"
840
840
  },
841
841
  _walk: function(visitor) {
842
- return visitor._visit(this, function(){
842
+ return visitor._visit(this, function() {
843
843
  this.left._walk(visitor);
844
844
  this.right._walk(visitor);
845
845
  });
@@ -854,7 +854,7 @@ var AST_Conditional = DEFNODE("Conditional", "condition consequent alternative",
854
854
  alternative: "[AST_Node]"
855
855
  },
856
856
  _walk: function(visitor) {
857
- return visitor._visit(this, function(){
857
+ return visitor._visit(this, function() {
858
858
  this.condition._walk(visitor);
859
859
  this.consequent._walk(visitor);
860
860
  this.alternative._walk(visitor);
@@ -878,7 +878,7 @@ var AST_Array = DEFNODE("Array", "elements", {
878
878
  elements: "[AST_Node*] array of elements"
879
879
  },
880
880
  _walk: function(visitor) {
881
- return visitor._visit(this, function(){
881
+ return visitor._visit(this, function() {
882
882
  var elements = this.elements;
883
883
  for (var i = 0, len = elements.length; i < len; i++) {
884
884
  elements[i]._walk(visitor);
@@ -893,7 +893,7 @@ var AST_Object = DEFNODE("Object", "properties", {
893
893
  properties: "[AST_ObjectProperty*] array of properties"
894
894
  },
895
895
  _walk: function(visitor) {
896
- return visitor._visit(this, function(){
896
+ return visitor._visit(this, function() {
897
897
  var properties = this.properties;
898
898
  for (var i = 0, len = properties.length; i < len; i++) {
899
899
  properties[i]._walk(visitor);
@@ -909,7 +909,7 @@ var AST_ObjectProperty = DEFNODE("ObjectProperty", "key value", {
909
909
  value: "[AST_Node] property value. For getters and setters this is an AST_Accessor."
910
910
  },
911
911
  _walk: function(visitor) {
912
- return visitor._visit(this, function(){
912
+ return visitor._visit(this, function() {
913
913
  if (this.key instanceof AST_Node)
914
914
  this.key._walk(visitor);
915
915
  this.value._walk(visitor);
@@ -958,14 +958,14 @@ var AST_Class = DEFNODE("Class", "name extends properties inlined", {
958
958
  },
959
959
  $documentation: "An ES6 class",
960
960
  _walk: function(visitor) {
961
- return visitor._visit(this, function(){
961
+ return visitor._visit(this, function() {
962
962
  if (this.name) {
963
963
  this.name._walk(visitor);
964
964
  }
965
965
  if (this.extends) {
966
966
  this.extends._walk(visitor);
967
967
  }
968
- this.properties.forEach(function(prop){
968
+ this.properties.forEach(function(prop) {
969
969
  prop._walk(visitor);
970
970
  });
971
971
  });
@@ -1107,11 +1107,10 @@ var AST_Number = DEFNODE("Number", "value literal", {
1107
1107
  }
1108
1108
  }, AST_Constant);
1109
1109
 
1110
- var AST_RegExp = DEFNODE("RegExp", "value raw", {
1110
+ var AST_RegExp = DEFNODE("RegExp", "value", {
1111
1111
  $documentation: "A regexp literal",
1112
1112
  $propdoc: {
1113
1113
  value: "[RegExp] the actual regexp",
1114
- raw: "[string] the raw regexp source"
1115
1114
  }
1116
1115
  }, AST_Constant);
1117
1116
 
@@ -1131,12 +1130,12 @@ var AST_NaN = DEFNODE("NaN", null, {
1131
1130
 
1132
1131
  var AST_Undefined = DEFNODE("Undefined", null, {
1133
1132
  $documentation: "The `undefined` value",
1134
- value: (function(){}())
1133
+ value: (function() {}())
1135
1134
  }, AST_Atom);
1136
1135
 
1137
1136
  var AST_Hole = DEFNODE("Hole", null, {
1138
1137
  $documentation: "A hole in an array",
1139
- value: (function(){}())
1138
+ value: (function() {}())
1140
1139
  }, AST_Atom);
1141
1140
 
1142
1141
  var AST_Infinity = DEFNODE("Infinity", null, {
@@ -1164,7 +1163,7 @@ var AST_Await = DEFNODE("Await", "expression", {
1164
1163
  expression: "[AST_Node] the mandatory expression being awaited",
1165
1164
  },
1166
1165
  _walk: function(visitor) {
1167
- return visitor._visit(this, function(){
1166
+ return visitor._visit(this, function() {
1168
1167
  this.expression._walk(visitor);
1169
1168
  });
1170
1169
  }
@@ -1177,7 +1176,7 @@ var AST_Yield = DEFNODE("Yield", "expression is_star", {
1177
1176
  is_star: "[Boolean] Whether this is a yield or yield* statement"
1178
1177
  },
1179
1178
  _walk: function(visitor) {
1180
- return visitor._visit(this, this.expression && function(){
1179
+ return visitor._visit(this, this.expression && function() {
1181
1180
  this.expression._walk(visitor);
1182
1181
  });
1183
1182
  }
@@ -1189,11 +1188,11 @@ function TreeWalker(callback) {
1189
1188
  this.visit = callback;
1190
1189
  this.stack = [];
1191
1190
  this.directives = Object.create(null);
1192
- };
1191
+ }
1193
1192
  TreeWalker.prototype = {
1194
1193
  _visit: function(node, descend) {
1195
1194
  this.push(node);
1196
- var ret = this.visit(node, descend ? function(){
1195
+ var ret = this.visit(node, descend ? function() {
1197
1196
  descend.call(node);
1198
1197
  } : noop);
1199
1198
  if (!ret && descend) {