terser 3.17.0 → 4.0.0

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/dist/bundle.js CHANGED
@@ -150,7 +150,7 @@
150
150
  }
151
151
  return is_last;
152
152
  }
153
- if (a instanceof Array) {
153
+ if (Array.isArray(a)) {
154
154
  if (backwards) {
155
155
  for (i = a.length; --i >= 0;) if (doit()) break;
156
156
  ret.reverse();
@@ -214,50 +214,10 @@
214
214
  return _ms(array);
215
215
  }
216
216
 
217
- // this function is taken from Acorn [1], written by Marijn Haverbeke
218
- // [1] https://github.com/marijnh/acorn
219
217
  function makePredicate(words) {
220
- if (!(words instanceof Array)) words = words.split(" ");
221
- var f = "", cats = [];
222
- out: for (var i = 0; i < words.length; ++i) {
223
- for (var j = 0; j < cats.length; ++j)
224
- if (cats[j][0].length == words[i].length) {
225
- cats[j].push(words[i]);
226
- continue out;
227
- }
228
- cats.push([words[i]]);
229
- }
230
- function quote(word) {
231
- return JSON.stringify(word).replace(/[\u2028\u2029]/g, function(s) {
232
- switch (s) {
233
- case "\u2028": return "\\u2028";
234
- case "\u2029": return "\\u2029";
235
- }
236
- return s;
237
- });
238
- }
239
- function compareTo(arr) {
240
- if (arr.length == 1) return f += "return str === " + quote(arr[0]) + ";";
241
- f += "switch(str){";
242
- for (var i = 0; i < arr.length; ++i) f += "case " + quote(arr[i]) + ":";
243
- f += "return true}return false;";
244
- }
245
- // When there are more than three length categories, an outer
246
- // switch first dispatches on the lengths, to save on comparisons.
247
- if (cats.length > 3) {
248
- cats.sort(function(a, b) {return b.length - a.length;});
249
- f += "switch(str.length){";
250
- for (var i = 0; i < cats.length; ++i) {
251
- var cat = cats[i];
252
- f += "case " + cat[0].length + ":";
253
- compareTo(cat);
254
- }
255
- f += "}";
256
- // Otherwise, simply generate a flat `switch` statement.
257
- } else {
258
- compareTo(words);
259
- }
260
- return new Function("str", f);
218
+ if (!Array.isArray(words)) words = words.split(" ");
219
+
220
+ return new Set(words);
261
221
  }
262
222
 
263
223
  function all(array, predicate) {
@@ -267,60 +227,31 @@
267
227
  return true;
268
228
  }
269
229
 
270
- function Dictionary() {
271
- this._values = Object.create(null);
272
- this._size = 0;
230
+ function map_add(map, key, value) {
231
+ if (map.has(key)) {
232
+ map.get(key).push(value);
233
+ } else {
234
+ map.set(key, [ value ]);
235
+ }
273
236
  }
274
- Dictionary.prototype = {
275
- set: function(key, val) {
276
- if (!this.has(key)) ++this._size;
277
- this._values["$" + key] = val;
278
- return this;
279
- },
280
- add: function(key, val) {
281
- if (this.has(key)) {
282
- this.get(key).push(val);
283
- } else {
284
- this.set(key, [ val ]);
285
- }
286
- return this;
287
- },
288
- get: function(key) { return this._values["$" + key]; },
289
- del: function(key) {
290
- if (this.has(key)) {
291
- --this._size;
292
- delete this._values["$" + key];
237
+
238
+ function map_from_object(obj) {
239
+ var map = new Map();
240
+ for (var key in obj) {
241
+ if (HOP(obj, key) && key.charAt(0) === "$") {
242
+ map.set(key.substr(1), obj[key]);
293
243
  }
294
- return this;
295
- },
296
- has: function(key) { return ("$" + key) in this._values; },
297
- each: function(f) {
298
- for (var i in this._values)
299
- f(this._values[i], i.substr(1));
300
- },
301
- size: function() {
302
- return this._size;
303
- },
304
- map: function(f) {
305
- var ret = [];
306
- for (var i in this._values)
307
- ret.push(f(this._values[i], i.substr(1)));
308
- return ret;
309
- },
310
- clone: function() {
311
- var ret = new Dictionary();
312
- for (var i in this._values)
313
- ret._values[i] = this._values[i];
314
- ret._size = this._size;
315
- return ret;
316
- },
317
- toObject: function() { return this._values; }
318
- };
319
- Dictionary.fromObject = function(obj) {
320
- var dict = new Dictionary();
321
- dict._size = merge(dict._values, obj);
322
- return dict;
323
- };
244
+ }
245
+ return map;
246
+ }
247
+
248
+ function map_to_object(map) {
249
+ var obj = Object.create(null);
250
+ map.forEach(function (value, key) {
251
+ obj["$" + key] = value;
252
+ });
253
+ return obj;
254
+ }
324
255
 
325
256
  function HOP(obj, prop) {
326
257
  return Object.prototype.hasOwnProperty.call(obj, prop);
@@ -551,10 +482,6 @@
551
482
  return code >= 48 && code <= 57;
552
483
  }
553
484
 
554
- function is_identifier(name) {
555
- return typeof name === "string" && !RESERVED_WORDS(name);
556
- }
557
-
558
485
  function is_identifier_start(ch) {
559
486
  var code = ch.charCodeAt(0);
560
487
  return UNICODE.ID_Start.test(ch) || code == 36 || code == 95;
@@ -639,7 +566,7 @@
639
566
  var ch = get_full_char(S.text, S.pos++);
640
567
  if (signal_eof && !ch)
641
568
  throw EX_EOF;
642
- if (NEWLINE_CHARS(ch)) {
569
+ if (NEWLINE_CHARS.has(ch)) {
643
570
  S.newline_before = S.newline_before || !in_string;
644
571
  ++S.line;
645
572
  S.col = 0;
@@ -670,7 +597,7 @@
670
597
  var text = S.text;
671
598
  for (var i = S.pos, n = S.text.length; i < n; ++i) {
672
599
  var ch = text[i];
673
- if (NEWLINE_CHARS(ch))
600
+ if (NEWLINE_CHARS.has(ch))
674
601
  return i;
675
602
  }
676
603
  return -1;
@@ -691,9 +618,9 @@
691
618
  var prev_was_dot = false;
692
619
  var previous_token = null;
693
620
  function token(type, value, is_comment) {
694
- S.regex_allowed = ((type == "operator" && !UNARY_POSTFIX(value)) ||
695
- (type == "keyword" && KEYWORDS_BEFORE_EXPRESSION(value)) ||
696
- (type == "punc" && PUNC_BEFORE_EXPRESSION(value))) ||
621
+ S.regex_allowed = ((type == "operator" && !UNARY_POSTFIX.has(value)) ||
622
+ (type == "keyword" && KEYWORDS_BEFORE_EXPRESSION.has(value)) ||
623
+ (type == "punc" && PUNC_BEFORE_EXPRESSION.has(value))) ||
697
624
  (type == "arrow");
698
625
  if (type == "punc" && value == ".") {
699
626
  prev_was_dot = true;
@@ -726,7 +653,7 @@
726
653
  }
727
654
 
728
655
  function skip_whitespace() {
729
- while (WHITESPACE_CHARS(peek()))
656
+ while (WHITESPACE_CHARS.has(peek()))
730
657
  next();
731
658
  }
732
659
 
@@ -851,7 +778,7 @@
851
778
  for (;;) {
852
779
  var ch = next(true, true);
853
780
  if (ch == "\\") ch = read_escaped_char(true, true);
854
- else if (NEWLINE_CHARS(ch)) parse_error("Unterminated string constant");
781
+ else if (NEWLINE_CHARS.has(ch)) parse_error("Unterminated string constant");
855
782
  else if (ch == quote) break;
856
783
  ret += ch;
857
784
  }
@@ -927,7 +854,7 @@
927
854
  });
928
855
 
929
856
  var read_name = with_eof_error("Unterminated identifier name", function() {
930
- var name = "", ch, escaped = false;
857
+ var name, ch, escaped = false;
931
858
  var read_escaped_identifier_char = function() {
932
859
  escaped = true;
933
860
  next();
@@ -964,7 +891,7 @@
964
891
  }
965
892
  name += ch;
966
893
  }
967
- if (RESERVED_WORDS(name) && escaped) {
894
+ if (RESERVED_WORDS.has(name) && escaped) {
968
895
  parse_error("Escaped characters are not allowed in keywords");
969
896
  }
970
897
  return name;
@@ -972,7 +899,7 @@
972
899
 
973
900
  var read_regexp = with_eof_error("Unterminated regular expression", function(source) {
974
901
  var prev_backslash = false, ch, in_class = false;
975
- while ((ch = next(true))) if (NEWLINE_CHARS(ch)) {
902
+ while ((ch = next(true))) if (NEWLINE_CHARS.has(ch)) {
976
903
  parse_error("Unexpected line terminator");
977
904
  } else if (prev_backslash) {
978
905
  source += "\\" + ch;
@@ -1004,7 +931,7 @@
1004
931
  function grow(op) {
1005
932
  if (!peek()) return op;
1006
933
  var bigger = op + peek();
1007
- if (OPERATORS(bigger)) {
934
+ if (OPERATORS.has(bigger)) {
1008
935
  next();
1009
936
  return grow(bigger);
1010
937
  } else {
@@ -1054,9 +981,9 @@
1054
981
  function read_word() {
1055
982
  var word = read_name();
1056
983
  if (prev_was_dot) return token("name", word);
1057
- return KEYWORDS_ATOM(word) ? token("atom", word)
1058
- : !KEYWORDS(word) ? token("name", word)
1059
- : OPERATORS(word) ? token("operator", word)
984
+ return KEYWORDS_ATOM.has(word) ? token("atom", word)
985
+ : !KEYWORDS.has(word) ? token("name", word)
986
+ : OPERATORS.has(word) ? token("operator", word)
1060
987
  : token("keyword", word);
1061
988
  }
1062
989
 
@@ -1118,8 +1045,8 @@
1118
1045
  break;
1119
1046
  }
1120
1047
  if (is_digit(code)) return read_num();
1121
- if (PUNC_CHARS(ch)) return token("punc", next());
1122
- if (OPERATOR_CHARS(ch)) return read_operator();
1048
+ if (PUNC_CHARS.has(ch)) return token("punc", next());
1049
+ if (OPERATOR_CHARS.has(ch)) return read_operator();
1123
1050
  if (code == 92 || is_identifier_start(ch)) return read_word();
1124
1051
  break;
1125
1052
  }
@@ -1732,20 +1659,20 @@
1732
1659
  };
1733
1660
 
1734
1661
  function track_used_binding_identifiers(is_parameter, strict) {
1735
- var parameters = {};
1662
+ var parameters = new Set();
1736
1663
  var duplicate = false;
1737
1664
  var default_assignment = false;
1738
1665
  var spread = false;
1739
1666
  var strict_mode = !!strict;
1740
1667
  var tracker = {
1741
1668
  add_parameter: function(token) {
1742
- if (parameters["$" + token.value] !== undefined) {
1669
+ if (parameters.has(token.value)) {
1743
1670
  if (duplicate === false) {
1744
1671
  duplicate = token;
1745
1672
  }
1746
1673
  tracker.check_strict();
1747
1674
  } else {
1748
- parameters["$" + token.value] = true;
1675
+ parameters.add(token.value);
1749
1676
  if (is_parameter) {
1750
1677
  switch (token.value) {
1751
1678
  case "arguments":
@@ -1756,7 +1683,7 @@
1756
1683
  }
1757
1684
  break;
1758
1685
  default:
1759
- if (RESERVED_WORDS(token.value)) {
1686
+ if (RESERVED_WORDS.has(token.value)) {
1760
1687
  unexpected();
1761
1688
  }
1762
1689
  }
@@ -2127,7 +2054,7 @@
2127
2054
  // Note 2: If there is a nlb between yield and star, it is interpret as
2128
2055
  // yield <explicit undefined> <inserted automatic semicolon> *
2129
2056
  if (can_insert_semicolon() ||
2130
- (is("punc") && PUNC_AFTER_EXPRESSION(S.token.value))) {
2057
+ (is("punc") && PUNC_AFTER_EXPRESSION.has(S.token.value))) {
2131
2058
  has_expression = false;
2132
2059
 
2133
2060
  } else if (is("operator", "*")) {
@@ -2498,7 +2425,7 @@
2498
2425
  if (is("template_head")) {
2499
2426
  return subscripts(template_string(false), allow_calls);
2500
2427
  }
2501
- if (ATOMIC_START_TOKEN(S.token.type)) {
2428
+ if (ATOMIC_START_TOKEN.has(S.token.type)) {
2502
2429
  return subscripts(as_atom_node(), allow_calls);
2503
2430
  }
2504
2431
  unexpected();
@@ -3126,7 +3053,7 @@
3126
3053
  token_error(S.token, "Unexpected await identifier inside strict mode");
3127
3054
  }
3128
3055
  }
3129
- if (is("operator") && UNARY_PREFIX(start.value)) {
3056
+ if (is("operator") && UNARY_PREFIX.has(start.value)) {
3130
3057
  next();
3131
3058
  handle_regexp();
3132
3059
  var ex = make_unary(AST_UnaryPrefix, start, maybe_unary(allow_calls));
@@ -3135,7 +3062,7 @@
3135
3062
  return ex;
3136
3063
  }
3137
3064
  var val = expr_atom(allow_calls, allow_arrows);
3138
- while (is("operator") && UNARY_POSTFIX(S.token.value) && !has_newline_before(S.token)) {
3065
+ while (is("operator") && UNARY_POSTFIX.has(S.token.value) && !has_newline_before(S.token)) {
3139
3066
  if (val instanceof AST_Arrow) unexpected();
3140
3067
  val = make_unary(AST_UnaryPostfix, S.token, val);
3141
3068
  val.start = start;
@@ -3270,7 +3197,7 @@
3270
3197
  var left = maybe_conditional(no_in);
3271
3198
  var val = S.token.value;
3272
3199
 
3273
- if (is("operator") && ASSIGNMENT(val)) {
3200
+ if (is("operator") && ASSIGNMENT.has(val)) {
3274
3201
  if (is_assignable(left) || (left = to_destructuring(left)) instanceof AST_Destructuring) {
3275
3202
  next();
3276
3203
  return new AST_Assign({
@@ -3650,8 +3577,8 @@
3650
3577
  var AST_Scope = DEFNODE("Scope", "variables functions uses_with uses_eval parent_scope enclosed cname", {
3651
3578
  $documentation: "Base class for all statements introducing a lexical scope",
3652
3579
  $propdoc: {
3653
- variables: "[Object/S] a map of name -> SymbolDef for all variables/functions defined in this scope",
3654
- functions: "[Object/S] like `variables`, but only lists function declarations",
3580
+ variables: "[Map/S] a map of name -> SymbolDef for all variables/functions defined in this scope",
3581
+ functions: "[Map/S] like `variables`, but only lists function declarations",
3655
3582
  uses_with: "[boolean/S] tells whether this scope uses the `with` statement",
3656
3583
  uses_eval: "[boolean/S] tells whether this scope contains a direct call to the global `eval`",
3657
3584
  parent_scope: "[AST_Scope?/S] link to the parent scope",
@@ -3667,8 +3594,8 @@
3667
3594
  },
3668
3595
  clone: function(deep) {
3669
3596
  var node = this._clone(deep);
3670
- if (this.variables) node.variables = this.variables.clone();
3671
- if (this.functions) node.functions = this.functions.clone();
3597
+ if (this.variables) node.variables = new Map(this.variables);
3598
+ if (this.functions) node.functions = new Map(this.functions);
3672
3599
  if (this.enclosed) node.enclosed = this.enclosed.slice();
3673
3600
  return node;
3674
3601
  },
@@ -3680,7 +3607,7 @@
3680
3607
  var AST_Toplevel = DEFNODE("Toplevel", "globals", {
3681
3608
  $documentation: "The toplevel scope",
3682
3609
  $propdoc: {
3683
- globals: "[Object/S] a map of name -> SymbolDef for all undeclared names",
3610
+ globals: "[Map/S] a map of name -> SymbolDef for all undeclared names",
3684
3611
  },
3685
3612
  wrap_commonjs: function(name) {
3686
3613
  var body = this.body;
@@ -4121,8 +4048,11 @@
4121
4048
  }
4122
4049
  });
4123
4050
 
4124
- var AST_Dot = DEFNODE("Dot", null, {
4051
+ var AST_Dot = DEFNODE("Dot", "quote", {
4125
4052
  $documentation: "A dotted property access expression",
4053
+ $propdoc: {
4054
+ quote: "[string] the original quote character when transformed from AST_Sub",
4055
+ },
4126
4056
  _walk: function(visitor) {
4127
4057
  return visitor._visit(this, function() {
4128
4058
  this.expression._walk(visitor);
@@ -4762,7 +4692,7 @@
4762
4692
 
4763
4693
  ***********************************************************************/
4764
4694
 
4765
- (function(undefined) {
4695
+ (function() {
4766
4696
 
4767
4697
  function _(node, descend) {
4768
4698
  node.DEFMETHOD("transform", function(tw, in_list) {
@@ -5278,16 +5208,18 @@
5278
5208
  might_need_semicolon = false;
5279
5209
 
5280
5210
  if (prev === ":" && ch === "}" || (!ch || !";}".includes(ch)) && prev !== ";") {
5281
- if (options.semicolons || requireSemicolonChars(ch)) {
5211
+ if (options.semicolons || requireSemicolonChars.has(ch)) {
5282
5212
  OUTPUT += ";";
5283
5213
  current_col++;
5284
5214
  current_pos++;
5285
5215
  } else {
5286
5216
  ensure_line_len();
5287
- OUTPUT += "\n";
5288
- current_pos++;
5289
- current_line++;
5290
- current_col = 0;
5217
+ if (current_col > 0) {
5218
+ OUTPUT += "\n";
5219
+ current_pos++;
5220
+ current_line++;
5221
+ current_col = 0;
5222
+ }
5291
5223
 
5292
5224
  if (/^\s+$/.test(str)) {
5293
5225
  // reset the semicolon flag, since we didn't print one
@@ -6120,7 +6052,7 @@
6120
6052
  AST_Arrow.DEFMETHOD("_do_print", function(output) {
6121
6053
  var self = this;
6122
6054
  var parent = output.parent();
6123
- var needs_parens = parent instanceof AST_Binary ||
6055
+ var needs_parens = (parent instanceof AST_Binary && !(parent instanceof AST_Assign)) ||
6124
6056
  parent instanceof AST_Unary ||
6125
6057
  (parent instanceof AST_Call && self === parent.expression);
6126
6058
  if (needs_parens) { output.print("("); }
@@ -6528,7 +6460,7 @@
6528
6460
  var expr = self.expression;
6529
6461
  expr.print(output);
6530
6462
  var prop = self.property;
6531
- if (output.option("ie8") && RESERVED_WORDS(prop)) {
6463
+ if (output.option("ie8") && RESERVED_WORDS.has(prop)) {
6532
6464
  output.print("[");
6533
6465
  output.add_mapping(self.end);
6534
6466
  output.print_string(prop);
@@ -6682,7 +6614,7 @@
6682
6614
  output.print_string(key);
6683
6615
  } else if ("" + +key == key && key >= 0) {
6684
6616
  output.print(make_num(key));
6685
- } else if (RESERVED_WORDS(key) ? !output.option("ie8") : is_identifier_string(key)) {
6617
+ } else if (RESERVED_WORDS.has(key) ? !output.option("ie8") : is_identifier_string(key)) {
6686
6618
  if (quote && output.option("keep_quoted_props")) {
6687
6619
  output.print_string(key, quote);
6688
6620
  } else {
@@ -6704,7 +6636,7 @@
6704
6636
  self.value instanceof AST_Symbol &&
6705
6637
  is_identifier_string(self.key) &&
6706
6638
  get_name(self.value) === self.key &&
6707
- is_identifier(self.key)
6639
+ !RESERVED_WORDS.has(self.key)
6708
6640
  ) {
6709
6641
  print_property_name(self.key, self.quote, output);
6710
6642
 
@@ -7027,7 +6959,7 @@
7027
6959
  // pass 1: setup scope chaining and handle definitions
7028
6960
  var self = this;
7029
6961
  var scope = self.parent_scope = null;
7030
- var labels = new Dictionary();
6962
+ var labels = new Map();
7031
6963
  var defun = null;
7032
6964
  var in_destructuring = null;
7033
6965
  var for_scopes = [];
@@ -7062,7 +6994,7 @@
7062
6994
  var save_defun = defun;
7063
6995
  var save_labels = labels;
7064
6996
  defun = scope = node;
7065
- labels = new Dictionary();
6997
+ labels = new Map();
7066
6998
  descend();
7067
6999
  scope = save_scope;
7068
7000
  defun = save_defun;
@@ -7076,7 +7008,7 @@
7076
7008
  }
7077
7009
  labels.set(l.name, l);
7078
7010
  descend();
7079
- labels.del(l.name);
7011
+ labels.delete(l.name);
7080
7012
  return true; // no descend again
7081
7013
  }
7082
7014
  if (node instanceof AST_With) {
@@ -7182,7 +7114,7 @@
7182
7114
  self.walk(tw);
7183
7115
 
7184
7116
  // pass 2: find back references and eval
7185
- self.globals = new Dictionary();
7117
+ self.globals = new Map();
7186
7118
  var tw = new TreeWalker(function(node, descend) {
7187
7119
  if (node instanceof AST_LoopControl && node.label) {
7188
7120
  node.label.thedef.references.push(node);
@@ -7250,7 +7182,7 @@
7250
7182
  if (options.safari10) {
7251
7183
  for (var i = 0; i < for_scopes.length; i++) {
7252
7184
  var scope = for_scopes[i];
7253
- scope.parent_scope.variables.each(function(def) {
7185
+ scope.parent_scope.variables.forEach(function(def) {
7254
7186
  push_uniq(scope.enclosed, def);
7255
7187
  });
7256
7188
  }
@@ -7271,8 +7203,8 @@
7271
7203
  });
7272
7204
 
7273
7205
  AST_Scope.DEFMETHOD("init_scope_vars", function(parent_scope) {
7274
- this.variables = new Dictionary(); // map name to AST_SymbolVar (variables defined in this scope; includes functions)
7275
- this.functions = new Dictionary(); // map name to AST_SymbolDefun (functions defined in this scope)
7206
+ this.variables = new Map(); // map name to AST_SymbolVar (variables defined in this scope; includes functions)
7207
+ this.functions = new Map(); // map name to AST_SymbolDefun (functions defined in this scope)
7276
7208
  this.uses_with = false; // will be set to true if this or some nested scope uses the `with` statement
7277
7209
  this.uses_eval = false; // will be set to true if this or nested scope uses the global `eval`
7278
7210
  this.parent_scope = parent_scope; // the parent scope
@@ -7309,7 +7241,7 @@
7309
7241
  while (s) {
7310
7242
  push_uniq(s.enclosed, def);
7311
7243
  if (options.keep_fnames) {
7312
- s.functions.each(function(d) {
7244
+ s.functions.forEach(function(d) {
7313
7245
  if (keep_name(options.keep_fnames, d.name)) {
7314
7246
  push_uniq(def.scope.enclosed, d);
7315
7247
  }
@@ -7357,7 +7289,7 @@
7357
7289
  var ext = scope.enclosed;
7358
7290
  out: while (true) {
7359
7291
  var m = base54(++scope.cname);
7360
- if (!is_identifier(m)) continue; // skip over "do"
7292
+ if (RESERVED_WORDS.has(m)) continue; // skip over "do"
7361
7293
 
7362
7294
  // https://github.com/mishoo/UglifyJS2/issues/242 -- do not
7363
7295
  // shadow a name reserved from mangling.
@@ -7455,9 +7387,9 @@
7455
7387
 
7456
7388
  var mangled_names = this.mangled_names = new Set();
7457
7389
  if (options.cache) {
7458
- this.globals.each(collect);
7390
+ this.globals.forEach(collect);
7459
7391
  if (options.cache.props) {
7460
- options.cache.props.each(function(mangled_name) {
7392
+ options.cache.props.forEach(function(mangled_name) {
7461
7393
  mangled_names.add(mangled_name);
7462
7394
  });
7463
7395
  }
@@ -7472,16 +7404,16 @@
7472
7404
  return true; // don't descend again in TreeWalker
7473
7405
  }
7474
7406
  if (node instanceof AST_Scope) {
7475
- node.variables.each(collect);
7407
+ node.variables.forEach(collect);
7476
7408
  return;
7477
7409
  }
7478
7410
  if (node.is_block_scope()) {
7479
- node.block_scope.variables.each(collect);
7411
+ node.block_scope.variables.forEach(collect);
7480
7412
  return;
7481
7413
  }
7482
7414
  if (node instanceof AST_Label) {
7483
7415
  var name;
7484
- do name = base54(++lname); while (!is_identifier(name));
7416
+ do name = base54(++lname); while (RESERVED_WORDS.has(name));
7485
7417
  node.mangled_name = name;
7486
7418
  return true;
7487
7419
  }
@@ -7504,17 +7436,17 @@
7504
7436
 
7505
7437
  AST_Toplevel.DEFMETHOD("find_colliding_names", function(options) {
7506
7438
  var cache = options.cache && options.cache.props;
7507
- var avoid = Object.create(null);
7439
+ var avoid = new Set();
7508
7440
  options.reserved.forEach(to_avoid);
7509
- this.globals.each(add_def);
7441
+ this.globals.forEach(add_def);
7510
7442
  this.walk(new TreeWalker(function(node) {
7511
- if (node instanceof AST_Scope) node.variables.each(add_def);
7443
+ if (node instanceof AST_Scope) node.variables.forEach(add_def);
7512
7444
  if (node instanceof AST_SymbolCatch) add_def(node.definition());
7513
7445
  }));
7514
7446
  return avoid;
7515
7447
 
7516
7448
  function to_avoid(name) {
7517
- avoid[name] = true;
7449
+ avoid.add(name);
7518
7450
  }
7519
7451
 
7520
7452
  function add_def(def) {
@@ -7531,9 +7463,9 @@
7531
7463
  options = this._default_mangler_options(options);
7532
7464
  var avoid = this.find_colliding_names(options);
7533
7465
  var cname = 0;
7534
- this.globals.each(rename);
7466
+ this.globals.forEach(rename);
7535
7467
  this.walk(new TreeWalker(function(node) {
7536
- if (node instanceof AST_Scope) node.variables.each(rename);
7468
+ if (node instanceof AST_Scope) node.variables.forEach(rename);
7537
7469
  if (node instanceof AST_SymbolCatch) rename(node.definition());
7538
7470
  }));
7539
7471
 
@@ -7541,7 +7473,7 @@
7541
7473
  var name;
7542
7474
  do {
7543
7475
  name = base54(cname++);
7544
- } while (avoid[name] || !is_identifier(name));
7476
+ } while (avoid.has(name) || RESERVED_WORDS.has(name));
7545
7477
  return name;
7546
7478
  }
7547
7479
 
@@ -7603,21 +7535,21 @@
7603
7535
  var digits = "0123456789".split("");
7604
7536
  var chars, frequency;
7605
7537
  function reset() {
7606
- frequency = Object.create(null);
7538
+ frequency = new Map();
7607
7539
  leading.forEach(function(ch) {
7608
- frequency[ch] = 0;
7540
+ frequency.set(ch, 0);
7609
7541
  });
7610
7542
  digits.forEach(function(ch) {
7611
- frequency[ch] = 0;
7543
+ frequency.set(ch, 0);
7612
7544
  });
7613
7545
  }
7614
7546
  base54.consider = function(str, delta) {
7615
7547
  for (var i = str.length; --i >= 0;) {
7616
- frequency[str[i]] += delta;
7548
+ frequency.set(str[i], frequency.get(str[i]) + delta);
7617
7549
  }
7618
7550
  };
7619
7551
  function compare(a, b) {
7620
- return frequency[b] - frequency[a];
7552
+ return frequency.get(b) - frequency.get(a);
7621
7553
  }
7622
7554
  base54.sort = function() {
7623
7555
  chars = mergeSort(leading, compare).concat(mergeSort(digits, compare));
@@ -8061,7 +7993,7 @@
8061
7993
  }
8062
7994
 
8063
7995
  function reset_variables(tw, compressor, node) {
8064
- node.variables.each(function(def) {
7996
+ node.variables.forEach(function(def) {
8065
7997
  reset_def(compressor, def);
8066
7998
  if (def.fixed === null) {
8067
7999
  def.safe_ids = tw.safe_ids;
@@ -8074,7 +8006,7 @@
8074
8006
  }
8075
8007
 
8076
8008
  function reset_block_variables(compressor, node) {
8077
- if (node.block_scope) node.block_scope.variables.each(function(def) {
8009
+ if (node.block_scope) node.block_scope.variables.forEach(function(def) {
8078
8010
  reset_def(compressor, def);
8079
8011
  });
8080
8012
  }
@@ -8152,7 +8084,7 @@
8152
8084
  return;
8153
8085
  } else if (parent instanceof AST_Array
8154
8086
  || parent instanceof AST_Await
8155
- || parent instanceof AST_Binary && lazy_op(parent.operator)
8087
+ || parent instanceof AST_Binary && lazy_op.has(parent.operator)
8156
8088
  || parent instanceof AST_Conditional && node !== parent.condition
8157
8089
  || parent instanceof AST_Expansion
8158
8090
  || parent instanceof AST_Sequence && node === parent.tail_node()) {
@@ -8221,7 +8153,7 @@
8221
8153
  return true;
8222
8154
  });
8223
8155
  def_reduce_vars(AST_Binary, function(tw) {
8224
- if (!lazy_op(this.operator)) return;
8156
+ if (!lazy_op.has(this.operator)) return;
8225
8157
  this.left.walk(tw);
8226
8158
  push(tw);
8227
8159
  this.right.walk(tw);
@@ -8409,7 +8341,7 @@
8409
8341
  mark_escaped(tw, d, this.scope, this, value, 0, 1);
8410
8342
  });
8411
8343
  def_reduce_vars(AST_Toplevel, function(tw, descend, compressor) {
8412
- this.globals.each(function(def) {
8344
+ this.globals.forEach(function(def) {
8413
8345
  reset_def(compressor, def);
8414
8346
  });
8415
8347
  reset_variables(tw, compressor, this);
@@ -8686,7 +8618,7 @@
8686
8618
  var global_names = makePredicate("Array Boolean clearInterval clearTimeout console Date decodeURI decodeURIComponent encodeURI encodeURIComponent Error escape eval EvalError Function isFinite isNaN JSON Math Number parseFloat parseInt RangeError ReferenceError RegExp Object setInterval setTimeout String SyntaxError TypeError unescape URIError");
8687
8619
  AST_SymbolRef.DEFMETHOD("is_declared", function(compressor) {
8688
8620
  return !this.definition().undeclared
8689
- || compressor.option("unsafe") && global_names(this.name);
8621
+ || compressor.option("unsafe") && global_names.has(this.name);
8690
8622
  });
8691
8623
 
8692
8624
  var identifier_atom = makePredicate("Infinity NaN undefined");
@@ -8786,7 +8718,7 @@
8786
8718
  }
8787
8719
  // Stop only if candidate is found within conditional branches
8788
8720
  if (!stop_if_hit && (!lhs_local || !replace_all)
8789
- && (parent instanceof AST_Binary && lazy_op(parent.operator) && parent.left !== node
8721
+ && (parent instanceof AST_Binary && lazy_op.has(parent.operator) && parent.left !== node
8790
8722
  || parent instanceof AST_Conditional && parent.condition !== node
8791
8723
  || parent instanceof AST_If && parent.condition !== node)) {
8792
8724
  stop_if_hit = parent;
@@ -8847,11 +8779,11 @@
8847
8779
  || node instanceof AST_PropAccess
8848
8780
  && (side_effects || node.expression.may_throw_on_access(compressor))
8849
8781
  || node instanceof AST_SymbolRef
8850
- && (lvalues[node.name] || side_effects && may_modify(node))
8782
+ && (lvalues.get(node.name) || side_effects && may_modify(node))
8851
8783
  || node instanceof AST_VarDef && node.value
8852
- && (node.name.name in lvalues || side_effects && may_modify(node.name))
8784
+ && (lvalues.has(node.name.name) || side_effects && may_modify(node.name))
8853
8785
  || (sym = is_lhs(node.left, node))
8854
- && (sym instanceof AST_PropAccess || sym.name in lvalues)
8786
+ && (sym instanceof AST_PropAccess || lvalues.has(sym.name))
8855
8787
  || may_throw
8856
8788
  && (in_try ? node.has_side_effects(compressor) : side_effects_external(node))) {
8857
8789
  stop_after = node;
@@ -8906,7 +8838,7 @@
8906
8838
  // Locate symbols which may execute code outside of scanning range
8907
8839
  var lvalues = get_lvalues(candidate);
8908
8840
  var lhs_local = is_lhs_local(lhs);
8909
- if (lhs instanceof AST_SymbolRef) lvalues[lhs.name] = false;
8841
+ if (lhs instanceof AST_SymbolRef) lvalues.set(lhs.name, false);
8910
8842
  var side_effects = value_has_side_effects(candidate);
8911
8843
  var replace_all = replace_all_symbols();
8912
8844
  var may_throw = candidate.may_throw(compressor);
@@ -9001,7 +8933,7 @@
9001
8933
  if (fn_strict && !member(fn_strict, fn.body)) fn_strict = false;
9002
8934
  var len = fn.argnames.length;
9003
8935
  args = iife.args.slice(len);
9004
- var names = Object.create(null);
8936
+ var names = new Set();
9005
8937
  for (var i = len; --i >= 0;) {
9006
8938
  var sym = fn.argnames[i];
9007
8939
  var arg = iife.args[i];
@@ -9009,8 +8941,8 @@
9009
8941
  name: sym,
9010
8942
  value: arg
9011
8943
  }));
9012
- if (sym.name in names) continue;
9013
- names[sym.name] = true;
8944
+ if (names.has(sym.name)) continue;
8945
+ names.add(sym.name);
9014
8946
  if (sym instanceof AST_Expansion) {
9015
8947
  var elements = iife.args.slice(i);
9016
8948
  if (all(elements, function(arg) {
@@ -9119,13 +9051,13 @@
9119
9051
  if (parent instanceof AST_Assign) {
9120
9052
  if (write_only
9121
9053
  && !(parent.left instanceof AST_PropAccess
9122
- || parent.left.name in lvalues)) {
9054
+ || lvalues.has(parent.left.name))) {
9123
9055
  return find_stop(parent, level + 1, write_only);
9124
9056
  }
9125
9057
  return node;
9126
9058
  }
9127
9059
  if (parent instanceof AST_Binary) {
9128
- if (write_only && (!lazy_op(parent.operator) || parent.left === node)) {
9060
+ if (write_only && (!lazy_op.has(parent.operator) || parent.left === node)) {
9129
9061
  return find_stop(parent, level + 1, write_only);
9130
9062
  }
9131
9063
  return node;
@@ -9193,13 +9125,13 @@
9193
9125
  }
9194
9126
 
9195
9127
  function get_lvalues(expr) {
9196
- var lvalues = Object.create(null);
9128
+ var lvalues = new Map();
9197
9129
  if (expr instanceof AST_Unary) return lvalues;
9198
9130
  var tw = new TreeWalker(function(node, descend) {
9199
9131
  var sym = node;
9200
9132
  while (sym instanceof AST_PropAccess) sym = sym.expression;
9201
9133
  if (sym instanceof AST_SymbolRef || sym instanceof AST_This) {
9202
- lvalues[sym.name] = lvalues[sym.name] || is_modified(compressor, tw, node, node, 0);
9134
+ lvalues.set(sym.name, lvalues.get(sym.name) || is_modified(compressor, tw, node, node, 0));
9203
9135
  }
9204
9136
  });
9205
9137
  get_rvalue(expr).walk(tw);
@@ -9244,7 +9176,7 @@
9244
9176
  return lhs instanceof AST_SymbolRef
9245
9177
  && lhs.definition().scope === scope
9246
9178
  && !(in_loop
9247
- && (lhs.name in lvalues
9179
+ && (lvalues.has(lhs.name)
9248
9180
  || candidate instanceof AST_Unary
9249
9181
  || candidate instanceof AST_Assign && candidate.operator != "="));
9250
9182
  }
@@ -9917,15 +9849,15 @@
9917
9849
 
9918
9850
  // methods to determine whether an expression has a boolean result type
9919
9851
  (function(def_is_boolean) {
9920
- var unary_bool = [ "!", "delete" ];
9921
- var binary_bool = [ "in", "instanceof", "==", "!=", "===", "!==", "<", "<=", ">=", ">" ];
9852
+ const unary_bool = makePredicate("! delete");
9853
+ const binary_bool = makePredicate("in instanceof == != === !== < <= >= >");
9922
9854
  def_is_boolean(AST_Node, return_false);
9923
9855
  def_is_boolean(AST_UnaryPrefix, function() {
9924
- return member(this.operator, unary_bool);
9856
+ return unary_bool.has(this.operator);
9925
9857
  });
9926
9858
  def_is_boolean(AST_Binary, function() {
9927
- return member(this.operator, binary_bool)
9928
- || lazy_op(this.operator)
9859
+ return binary_bool.has(this.operator)
9860
+ || lazy_op.has(this.operator)
9929
9861
  && this.left.is_boolean()
9930
9862
  && this.right.is_boolean();
9931
9863
  });
@@ -9950,16 +9882,16 @@
9950
9882
  def_is_number(AST_Number, return_true);
9951
9883
  var unary = makePredicate("+ - ~ ++ --");
9952
9884
  def_is_number(AST_Unary, function() {
9953
- return unary(this.operator);
9885
+ return unary.has(this.operator);
9954
9886
  });
9955
9887
  var binary = makePredicate("- * / % & | ^ << >> >>>");
9956
9888
  def_is_number(AST_Binary, function(compressor) {
9957
- return binary(this.operator) || this.operator == "+"
9889
+ return binary.has(this.operator) || this.operator == "+"
9958
9890
  && this.left.is_number(compressor)
9959
9891
  && this.right.is_number(compressor);
9960
9892
  });
9961
9893
  def_is_number(AST_Assign, function(compressor) {
9962
- return binary(this.operator.slice(0, -1))
9894
+ return binary.has(this.operator.slice(0, -1))
9963
9895
  || this.operator == "=" && this.right.is_number(compressor);
9964
9896
  });
9965
9897
  def_is_number(AST_Sequence, function(compressor) {
@@ -10003,7 +9935,7 @@
10003
9935
  var unary_side_effects = makePredicate("delete ++ --");
10004
9936
 
10005
9937
  function is_lhs(node, parent) {
10006
- if (parent instanceof AST_Unary && unary_side_effects(parent.operator)) return parent.expression;
9938
+ if (parent instanceof AST_Unary && unary_side_effects.has(parent.operator)) return parent.expression;
10007
9939
  if (parent instanceof AST_Assign && parent.left === node) return node;
10008
9940
  }
10009
9941
 
@@ -10090,7 +10022,7 @@
10090
10022
  }
10091
10023
 
10092
10024
  function convert_to_predicate(obj) {
10093
- for (var key in obj) {
10025
+ for (var key of Object.keys(obj)) {
10094
10026
  obj[key] = makePredicate(obj[key]);
10095
10027
  }
10096
10028
  }
@@ -10204,7 +10136,7 @@
10204
10136
  } else {
10205
10137
  return this instanceof AST_UnaryPrefix
10206
10138
  && this.expression instanceof AST_Constant
10207
- && unaryPrefix(this.operator);
10139
+ && unaryPrefix.has(this.operator);
10208
10140
  }
10209
10141
  });
10210
10142
  def_eval(AST_Statement, function() {
@@ -10280,7 +10212,7 @@
10280
10212
  && e.fixed_value() instanceof AST_Lambda)) {
10281
10213
  return typeof function() {};
10282
10214
  }
10283
- if (!non_converting_unary(this.operator)) depth++;
10215
+ if (!non_converting_unary.has(this.operator)) depth++;
10284
10216
  e = e._eval(compressor, depth);
10285
10217
  if (e === this.expression) return this;
10286
10218
  switch (this.operator) {
@@ -10299,7 +10231,7 @@
10299
10231
  });
10300
10232
  var non_converting_binary = makePredicate("&& || === !==");
10301
10233
  def_eval(AST_Binary, function(compressor, depth) {
10302
- if (!non_converting_binary(this.operator)) depth++;
10234
+ if (!non_converting_binary.has(this.operator)) depth++;
10303
10235
  var left = this.left._eval(compressor, depth);
10304
10236
  if (left === this.left) return this;
10305
10237
  var right = this.right._eval(compressor, depth);
@@ -10415,7 +10347,8 @@
10415
10347
  if (first_arg == null || first_arg.thedef && first_arg.thedef.undeclared) {
10416
10348
  return this.clone();
10417
10349
  }
10418
- if (!(static_values[exp.name] || return_false)(key)) return this;
10350
+ var static_value = static_values[exp.name];
10351
+ if (!static_value || !static_value.has(key)) return this;
10419
10352
  val = global_objs[exp.name];
10420
10353
  } else {
10421
10354
  val = exp._eval(compressor, depth + 1);
@@ -10454,11 +10387,14 @@
10454
10387
  if ((first_arg == null || first_arg.thedef && first_arg.thedef.undeclared)) {
10455
10388
  return this.clone();
10456
10389
  }
10457
- if (!(static_fns[e.name] || return_false)(key)) return this;
10390
+ var static_fn = static_fns[e.name];
10391
+ if (!static_fn || !static_fn.has(key)) return this;
10458
10392
  val = global_objs[e.name];
10459
10393
  } else {
10460
10394
  val = e._eval(compressor, depth + 1);
10461
- if (val === e || !(val && native_fns[val.constructor.name] || return_false)(key)) return this;
10395
+ if (val === e || !val) return this;
10396
+ var native_fn = native_fns[val.constructor.name];
10397
+ if (!native_fn || !native_fn.has(key)) return this;
10462
10398
  }
10463
10399
  var args = [];
10464
10400
  for (var i = 0, len = this.args.length; i < len; i++) {
@@ -10576,10 +10512,11 @@
10576
10512
  ) {
10577
10513
  return false;
10578
10514
  }
10579
- if (is_undeclared_ref(expr) && global_pure_fns(expr.name)) return true;
10515
+ if (is_undeclared_ref(expr) && global_pure_fns.has(expr.name)) return true;
10580
10516
  if (expr instanceof AST_Dot
10581
10517
  && is_undeclared_ref(expr.expression)
10582
- && (static_fns.hasOwnProperty(expr.expression.name) && static_fns[expr.expression.name] || return_false)(expr.property)) {
10518
+ && static_fns.hasOwnProperty(expr.expression.name)
10519
+ && static_fns[expr.expression.name].has(expr.property)) {
10583
10520
  return true;
10584
10521
  }
10585
10522
  }
@@ -10588,22 +10525,22 @@
10588
10525
  AST_Node.DEFMETHOD("is_call_pure", return_false);
10589
10526
  AST_Dot.DEFMETHOD("is_call_pure", function(compressor) {
10590
10527
  if (!compressor.option("unsafe")) return;
10591
- var expr = this.expression;
10592
- var fns = return_false;
10528
+ const expr = this.expression;
10529
+ let map;
10593
10530
  if (expr instanceof AST_Array) {
10594
- fns = native_fns.Array;
10531
+ map = native_fns.Array;
10595
10532
  } else if (expr.is_boolean()) {
10596
- fns = native_fns.Boolean;
10533
+ map = native_fns.Boolean;
10597
10534
  } else if (expr.is_number(compressor)) {
10598
- fns = native_fns.Number;
10535
+ map = native_fns.Number;
10599
10536
  } else if (expr instanceof AST_RegExp) {
10600
- fns = native_fns.RegExp;
10537
+ map = native_fns.RegExp;
10601
10538
  } else if (expr.is_string(compressor)) {
10602
- fns = native_fns.String;
10539
+ map = native_fns.String;
10603
10540
  } else if (!this.may_throw_on_access(compressor)) {
10604
- fns = native_fns.Object;
10541
+ map = native_fns.Object;
10605
10542
  }
10606
- return fns(this.property);
10543
+ return map && map.has(this.property);
10607
10544
  });
10608
10545
 
10609
10546
  // determine if expression has side effects
@@ -10670,7 +10607,7 @@
10670
10607
  || this.alternative.has_side_effects(compressor);
10671
10608
  });
10672
10609
  def_has_side_effects(AST_Unary, function(compressor) {
10673
- return unary_side_effects(this.operator)
10610
+ return unary_side_effects.has(this.operator)
10674
10611
  || this.expression.has_side_effects(compressor);
10675
10612
  });
10676
10613
  def_has_side_effects(AST_SymbolRef, function(compressor) {
@@ -11000,19 +10937,17 @@
11000
10937
  }
11001
10938
  if (node instanceof AST_Unary && node.write_only) return node.expression;
11002
10939
  };
11003
- var in_use = [];
11004
- var in_use_ids = Object.create(null); // avoid expensive linear scans of in_use
11005
- var fixed_ids = Object.create(null);
10940
+ var in_use_ids = new Map();
10941
+ var fixed_ids = new Map();
11006
10942
  if (self instanceof AST_Toplevel && compressor.top_retain) {
11007
- self.variables.each(function(def) {
11008
- if (compressor.top_retain(def) && !(def.id in in_use_ids)) {
11009
- in_use_ids[def.id] = true;
11010
- in_use.push(def);
10943
+ self.variables.forEach(function(def) {
10944
+ if (compressor.top_retain(def) && !in_use_ids.has(def.id)) {
10945
+ in_use_ids.set(def.id, def);
11011
10946
  }
11012
10947
  });
11013
10948
  }
11014
- var var_defs_by_id = new Dictionary();
11015
- var initializations = new Dictionary();
10949
+ var var_defs_by_id = new Map();
10950
+ var initializations = new Map();
11016
10951
  var destructuring_value = null;
11017
10952
  // pass 1: find out which symbols are directly used in
11018
10953
  // this scope (not in nested scopes).
@@ -11022,9 +10957,8 @@
11022
10957
  node.argnames.forEach(function(argname) {
11023
10958
  if (!(argname instanceof AST_SymbolDeclaration)) return;
11024
10959
  var def = argname.definition();
11025
- if (!(def.id in in_use_ids)) {
11026
- in_use_ids[def.id] = true;
11027
- in_use.push(def);
10960
+ if (!in_use_ids.has(def.id)) {
10961
+ in_use_ids.set(def.id, def);
11028
10962
  }
11029
10963
  });
11030
10964
  }
@@ -11033,30 +10967,28 @@
11033
10967
  var node_def = node.name.definition();
11034
10968
  var in_export = tw.parent() instanceof AST_Export;
11035
10969
  if (in_export || !drop_funcs && scope === self) {
11036
- if (node_def.global && !(node_def.id in in_use_ids)) {
11037
- in_use_ids[node_def.id] = true;
11038
- in_use.push(node_def);
10970
+ if (node_def.global && !in_use_ids.has(node_def.id)) {
10971
+ in_use_ids.set(node_def.id, node_def);
11039
10972
  }
11040
10973
  }
11041
- initializations.add(node_def.id, node);
10974
+ map_add(initializations, node_def.id, node);
11042
10975
  return true; // don't go in nested scopes
11043
10976
  }
11044
10977
  if (node instanceof AST_SymbolFunarg && scope === self) {
11045
- var_defs_by_id.add(node.definition().id, node);
10978
+ map_add(var_defs_by_id, node.definition().id, node);
11046
10979
  }
11047
10980
  if (node instanceof AST_Definitions && scope === self) {
11048
10981
  var in_export = tw.parent() instanceof AST_Export;
11049
10982
  node.definitions.forEach(function(def) {
11050
10983
  if (def.name instanceof AST_SymbolVar) {
11051
- var_defs_by_id.add(def.name.definition().id, def);
10984
+ map_add(var_defs_by_id, def.name.definition().id, def);
11052
10985
  }
11053
10986
  if (in_export || !drop_vars) {
11054
10987
  def.name.walk(new TreeWalker(function(node) {
11055
10988
  if (node instanceof AST_SymbolDeclaration) {
11056
10989
  var def = node.definition();
11057
- if ((in_export || def.global) && !(def.id in in_use_ids)) {
11058
- in_use_ids[def.id] = true;
11059
- in_use.push(def);
10990
+ if ((in_export || def.global) && !in_use_ids.has(def.id)) {
10991
+ in_use_ids.set(def.id, def);
11060
10992
  }
11061
10993
  }
11062
10994
  }));
@@ -11069,9 +11001,9 @@
11069
11001
  destructuring_value = destructuring_cache;
11070
11002
  } else {
11071
11003
  var node_def = def.name.definition();
11072
- initializations.add(node_def.id, def.value);
11004
+ map_add(initializations, node_def.id, def.value);
11073
11005
  if (!node_def.chained && def.name.fixed_value() === def.value) {
11074
- fixed_ids[node_def.id] = def;
11006
+ fixed_ids.set(node_def.id, def);
11075
11007
  }
11076
11008
  }
11077
11009
  if (def.value.has_side_effects(compressor)) {
@@ -11082,7 +11014,7 @@
11082
11014
  return true;
11083
11015
  }
11084
11016
  if (node.destructuring && destructuring_value) {
11085
- initializations.add(node.name, destructuring_value);
11017
+ map_add(initializations, node.name, destructuring_value);
11086
11018
  }
11087
11019
  return scan_ref_scoped(node, descend);
11088
11020
  });
@@ -11091,12 +11023,12 @@
11091
11023
  // initialization code to figure out if it uses other
11092
11024
  // symbols (that may not be in_use).
11093
11025
  tw = new TreeWalker(scan_ref_scoped);
11094
- for (var i = 0; i < in_use.length; i++) {
11095
- var init = initializations.get(in_use[i].id);
11026
+ in_use_ids.forEach(function (def) {
11027
+ var init = initializations.get(def.id);
11096
11028
  if (init) init.forEach(function(init) {
11097
11029
  init.walk(tw);
11098
11030
  });
11099
- }
11031
+ });
11100
11032
  // pass 3: we should drop declarations not in_use
11101
11033
  var tt = new TreeTransformer(
11102
11034
  function before(node, descend, in_list) {
@@ -11105,9 +11037,9 @@
11105
11037
  var sym = assign_as_unused(node);
11106
11038
  if (sym instanceof AST_SymbolRef) {
11107
11039
  var def = sym.definition();
11108
- var in_use = def.id in in_use_ids;
11040
+ var in_use = in_use_ids.has(def.id);
11109
11041
  if (node instanceof AST_Assign) {
11110
- if (!in_use || def.id in fixed_ids && fixed_ids[def.id] !== node) {
11042
+ if (!in_use || fixed_ids.has(def.id) && fixed_ids.get(def.id) !== node) {
11111
11043
  return maintain_this_binding(parent, node, node.right.transform(tt));
11112
11044
  }
11113
11045
  } else if (!in_use) return make_node(AST_Number, node, {
@@ -11125,7 +11057,7 @@
11125
11057
  // any declarations with same name will overshadow
11126
11058
  // name of this anonymous function and can therefore
11127
11059
  // never be used anywhere
11128
- if (!(def.id in in_use_ids) || def.orig.length > 1) node.name = null;
11060
+ if (!in_use_ids.has(def.id) || def.orig.length > 1) node.name = null;
11129
11061
  }
11130
11062
  if (node instanceof AST_Lambda && !(node instanceof AST_Accessor)) {
11131
11063
  var trim = !compressor.option("keep_fargs");
@@ -11142,7 +11074,7 @@
11142
11074
  // them would stop that TypeError which would happen
11143
11075
  // if someone called it with an incorrectly formatted
11144
11076
  // parameter.
11145
- if (!(sym instanceof AST_Destructuring) && !(sym.definition().id in in_use_ids)) {
11077
+ if (!(sym instanceof AST_Destructuring) && !in_use_ids.has(sym.definition().id)) {
11146
11078
  sym.__unused = true;
11147
11079
  if (trim) {
11148
11080
  a.pop();
@@ -11155,7 +11087,7 @@
11155
11087
  }
11156
11088
  if ((node instanceof AST_Defun || node instanceof AST_DefClass) && node !== self) {
11157
11089
  var def = node.name.definition();
11158
- var keep = (def.id in in_use_ids) || !drop_funcs && def.global;
11090
+ var keep = in_use_ids.has(def.id) || !drop_funcs && def.global;
11159
11091
  if (!keep) {
11160
11092
  compressor[node.name.unreferenced() ? "warn" : "info"]("Dropping unused function {name} [{file}:{line},{col}]", template(node.name));
11161
11093
  def.eliminated++;
@@ -11182,8 +11114,8 @@
11182
11114
  && (def.name.names.length
11183
11115
  || def.name.is_array
11184
11116
  || compressor.option("pure_getters") != true)
11185
- || sym.id in in_use_ids) {
11186
- if (def.value && sym.id in fixed_ids && fixed_ids[sym.id] !== def) {
11117
+ || in_use_ids.has(sym.id)) {
11118
+ if (def.value && fixed_ids.has(sym.id) && fixed_ids.get(sym.id) !== def) {
11187
11119
  def.value = def.value.drop_side_effect_free(compressor);
11188
11120
  }
11189
11121
  if (def.name instanceof AST_SymbolVar) {
@@ -11198,8 +11130,8 @@
11198
11130
  left: ref,
11199
11131
  right: def.value
11200
11132
  });
11201
- if (fixed_ids[sym.id] === def) {
11202
- fixed_ids[sym.id] = assign;
11133
+ if (fixed_ids.get(sym.id) === def) {
11134
+ fixed_ids.set(sym.id, assign);
11203
11135
  }
11204
11136
  side_effects.push(assign.transform(tt));
11205
11137
  }
@@ -11326,19 +11258,17 @@
11326
11258
  if (node instanceof AST_Assign) {
11327
11259
  node.right.walk(tw);
11328
11260
  if (!node_def.chained && node.left.fixed_value() === node.right) {
11329
- fixed_ids[node_def.id] = node;
11261
+ fixed_ids.set(node_def.id, node);
11330
11262
  }
11331
11263
  }
11332
11264
  return true;
11333
11265
  }
11334
11266
  if (node instanceof AST_SymbolRef) {
11335
11267
  node_def = node.definition();
11336
- if (!(node_def.id in in_use_ids)) {
11337
- in_use_ids[node_def.id] = true;
11338
- in_use.push(node_def);
11268
+ if (!in_use_ids.has(node_def.id)) {
11269
+ in_use_ids.set(node_def.id, node_def);
11339
11270
  if (node_def = node_def.redefined()) {
11340
- in_use_ids[node_def.id] = true;
11341
- in_use.push(node_def);
11271
+ in_use_ids.set(node_def.id, node_def);
11342
11272
  }
11343
11273
  }
11344
11274
  return true;
@@ -11365,7 +11295,7 @@
11365
11295
  if (hoist_funs || hoist_vars) {
11366
11296
  var dirs = [];
11367
11297
  var hoisted = [];
11368
- var vars = new Dictionary(), vars_found = 0, var_decl = 0;
11298
+ var vars = new Map(), vars_found = 0, var_decl = 0;
11369
11299
  // let's count var_decl first, we seem to waste a lot of
11370
11300
  // space if we hoist `var` when there's only one.
11371
11301
  self.walk(new TreeWalker(function(node) {
@@ -11422,11 +11352,11 @@
11422
11352
  if (vars_found > 0) {
11423
11353
  // collect only vars which don't show up in self's arguments list
11424
11354
  var defs = [];
11425
- vars.each(function(def, name) {
11355
+ vars.forEach(function(def, name) {
11426
11356
  if (self instanceof AST_Lambda
11427
11357
  && find_if(function(x) { return x.name == def.name.name; },
11428
11358
  self.args_as_names())) {
11429
- vars.del(name);
11359
+ vars.delete(name);
11430
11360
  } else {
11431
11361
  def = def.clone();
11432
11362
  def.value = null;
@@ -11492,13 +11422,12 @@
11492
11422
  AST_Scope.DEFMETHOD("var_names", function varNames() {
11493
11423
  var var_names = this._var_names;
11494
11424
  if (!var_names) {
11495
- const isParentScopeAvailable = this.parent_scope && !this.parent_scope instanceof AST_Toplevel;
11496
- this._var_names = var_names = isParentScopeAvailable ? varNames.call(this.parent_scope) : Object.create(null);
11425
+ this._var_names = var_names = new Set(this.parent_scope ? varNames.call(this.parent_scope) : null);
11497
11426
  this.enclosed.forEach(function(def) {
11498
- var_names[def.name] = true;
11427
+ var_names.add(def.name);
11499
11428
  });
11500
- this.variables.each(function(def, name) {
11501
- var_names[name] = true;
11429
+ this.variables.forEach(function(def, name) {
11430
+ var_names.add(name);
11502
11431
  });
11503
11432
  }
11504
11433
  return var_names;
@@ -11508,8 +11437,8 @@
11508
11437
  var var_names = this.var_names();
11509
11438
  prefix = prefix.replace(/(?:^[^a-z_$]|[^a-z0-9_$])/ig, "_");
11510
11439
  var name = prefix;
11511
- for (var i = 0; var_names[name]; i++) name = prefix + "$" + i;
11512
- var_names[name] = true;
11440
+ for (var i = 0; var_names.has(name); i++) name = prefix + "$" + i;
11441
+ var_names.add(name);
11513
11442
  return name;
11514
11443
  });
11515
11444
 
@@ -11517,7 +11446,7 @@
11517
11446
  var self = this;
11518
11447
  if (!compressor.option("hoist_props") || compressor.has_directive("use asm")) return self;
11519
11448
  var top_retain = self instanceof AST_Toplevel && compressor.top_retain || return_false;
11520
- var defs_by_id = Object.create(null);
11449
+ var defs_by_id = new Map();
11521
11450
  var tt = new TreeTransformer(function(node, descend) {
11522
11451
  if (node instanceof AST_Definitions && tt.parent() instanceof AST_Export) return node;
11523
11452
  if (node instanceof AST_VarDef) {
@@ -11532,7 +11461,7 @@
11532
11461
  && (value = sym.fixed_value()) === node.value
11533
11462
  && value instanceof AST_Object) {
11534
11463
  descend(node, this);
11535
- var defs = new Dictionary();
11464
+ var defs = new Map();
11536
11465
  var assignments = [];
11537
11466
  value.properties.forEach(function(prop) {
11538
11467
  assignments.push(make_node(AST_VarDef, node, {
@@ -11540,14 +11469,14 @@
11540
11469
  value: prop.value
11541
11470
  }));
11542
11471
  });
11543
- defs_by_id[def.id] = defs;
11472
+ defs_by_id.set(def.id, defs);
11544
11473
  return MAP.splice(assignments);
11545
11474
  }
11546
11475
  }
11547
11476
  if (node instanceof AST_PropAccess && node.expression instanceof AST_SymbolRef) {
11548
- var defs = defs_by_id[node.expression.definition().id];
11477
+ var defs = defs_by_id.get(node.expression.definition().id);
11549
11478
  if (defs) {
11550
- var def = defs.get(get_value(node.property));
11479
+ var def = defs.get(String(get_value(node.property)));
11551
11480
  var sym = make_node(AST_SymbolRef, node, {
11552
11481
  name: def.name,
11553
11482
  scope: node.expression.scope,
@@ -11564,7 +11493,7 @@
11564
11493
  scope: self
11565
11494
  });
11566
11495
  var def = self.def_variable(new_var);
11567
- defs.set(key, def);
11496
+ defs.set(String(key), def);
11568
11497
  self.enclosed.push(def);
11569
11498
  return new_var;
11570
11499
  }
@@ -11626,7 +11555,7 @@
11626
11555
  def_drop_side_effect_free(AST_Binary, function(compressor, first_in_statement$$1) {
11627
11556
  var right = this.right.drop_side_effect_free(compressor);
11628
11557
  if (!right) return this.left.drop_side_effect_free(compressor, first_in_statement$$1);
11629
- if (lazy_op(this.operator)) {
11558
+ if (lazy_op.has(this.operator)) {
11630
11559
  if (right === this.right) return this;
11631
11560
  var node = this.clone();
11632
11561
  node.right = right;
@@ -11674,7 +11603,7 @@
11674
11603
  return node;
11675
11604
  });
11676
11605
  def_drop_side_effect_free(AST_Unary, function(compressor, first_in_statement$$1) {
11677
- if (unary_side_effects(this.operator)) {
11606
+ if (unary_side_effects.has(this.operator)) {
11678
11607
  this.write_only = !this.expression.has_side_effects(compressor);
11679
11608
  return this;
11680
11609
  }
@@ -12311,6 +12240,10 @@
12311
12240
  return make_node(AST_Array, self, {
12312
12241
  elements: self.args
12313
12242
  }).optimize(compressor);
12243
+ } else if (self.args[0] instanceof AST_Number && self.args[0].value <= 11) {
12244
+ const elements = [];
12245
+ for (let i = 0; i < self.args[0].value; i++) elements.push(new AST_Hole);
12246
+ return new AST_Array({ elements });
12314
12247
  }
12315
12248
  break;
12316
12249
  case "Object":
@@ -12670,9 +12603,9 @@
12670
12603
  }
12671
12604
  if (arg.__unused) continue;
12672
12605
  if (!safe_to_inject
12673
- || block_scoped[arg.name]
12674
- || identifier_atom(arg.name)
12675
- || scope.var_names()[arg.name]) {
12606
+ || block_scoped.has(arg.name)
12607
+ || identifier_atom.has(arg.name)
12608
+ || scope.var_names().has(arg.name)) {
12676
12609
  return false;
12677
12610
  }
12678
12611
  if (in_loop) in_loop.push(arg.definition());
@@ -12689,9 +12622,9 @@
12689
12622
  for (var j = stat.definitions.length; --j >= 0;) {
12690
12623
  var name = stat.definitions[j].name;
12691
12624
  if (name instanceof AST_Destructuring
12692
- || block_scoped[name.name]
12693
- || identifier_atom(name.name)
12694
- || scope.var_names()[name.name]) {
12625
+ || block_scoped.has(name.name)
12626
+ || identifier_atom.has(name.name)
12627
+ || scope.var_names().has(name.name)) {
12695
12628
  return false;
12696
12629
  }
12697
12630
  if (in_loop) in_loop.push(name.definition());
@@ -12701,21 +12634,21 @@
12701
12634
  }
12702
12635
 
12703
12636
  function can_inject_symbols() {
12704
- var block_scoped = Object.create(null);
12637
+ var block_scoped = new Set();
12705
12638
  do {
12706
12639
  scope = compressor.parent(++level);
12707
12640
  if (scope.is_block_scope() && !(compressor.parent(level - 1) instanceof AST_Scope)) {
12708
12641
  if (scope.block_scope) {
12709
12642
  // TODO this is sometimes undefined during compression.
12710
12643
  // But it should always have a value!
12711
- scope.block_scope.variables.each(function (variable) {
12712
- block_scoped[variable.name] = true;
12644
+ scope.block_scope.variables.forEach(function (variable) {
12645
+ block_scoped.add(variable.name);
12713
12646
  });
12714
12647
  }
12715
12648
  }
12716
12649
  if (scope instanceof AST_Catch) {
12717
12650
  if (scope.argname) {
12718
- block_scoped[scope.argname.name] = true;
12651
+ block_scoped.add(scope.argname.name);
12719
12652
  }
12720
12653
  } else if (scope instanceof AST_IterationStatement) {
12721
12654
  in_loop = [];
@@ -12734,8 +12667,8 @@
12734
12667
  var def = name.definition();
12735
12668
  scope.variables.set(name.name, def);
12736
12669
  scope.enclosed.push(def);
12737
- if (!scope.var_names()[name.name]) {
12738
- scope.var_names()[name.name] = true;
12670
+ if (!scope.var_names().has(name.name)) {
12671
+ scope.var_names().add(name.name);
12739
12672
  decls.push(make_node(AST_VarDef, name, {
12740
12673
  name: name,
12741
12674
  value: null
@@ -12758,7 +12691,7 @@
12758
12691
  for (i = len; --i >= 0;) {
12759
12692
  var name = fn.argnames[i];
12760
12693
  var value = self.args[i];
12761
- if (name.__unused || !name.name || scope.var_names()[name.name]) {
12694
+ if (name.__unused || !name.name || scope.var_names().has(name.name)) {
12762
12695
  if (value) expressions.push(value);
12763
12696
  } else {
12764
12697
  var symbol = make_node(AST_SymbolVar, name, name);
@@ -12813,26 +12746,11 @@
12813
12746
  });
12814
12747
 
12815
12748
  def_optimize(AST_New, function(self, compressor) {
12816
- const {args, expression: exp} = self;
12817
-
12818
- if (compressor.option("unsafe") && is_undeclared_ref(exp)) {
12819
- if (["Object", "RegExp", "Function", "Error"].includes(exp.name))
12820
- return make_node(AST_Call, self, self).transform(compressor);
12821
-
12822
- if (exp.name === "Array" && args.length < 2) {
12823
- if (args.length === 0 || args[0].value === 0) return new AST_Array;
12824
-
12825
- if (args[0].value > 11) {
12826
- return make_node(AST_Call, self, self).transform(compressor);
12827
- }
12828
-
12829
- const elements = [];
12830
- for (let i = 0; i < self.args[0].value; i++) elements.push(new AST_Hole);
12831
-
12832
- return new AST_Array({elements});
12833
- }
12834
- }
12835
-
12749
+ if (
12750
+ compressor.option("unsafe") &&
12751
+ is_undeclared_ref(self.expression) &&
12752
+ ["Object", "RegExp", "Function", "Error", "Array"].includes(self.expression.name)
12753
+ ) return make_node(AST_Call, self, self).transform(compressor);
12836
12754
  return self;
12837
12755
  });
12838
12756
 
@@ -13022,7 +12940,7 @@
13022
12940
  self.right = tmp;
13023
12941
  }
13024
12942
  }
13025
- if (commutativeOperators(self.operator)) {
12943
+ if (commutativeOperators.has(self.operator)) {
13026
12944
  if (self.right.is_constant()
13027
12945
  && !self.left.is_constant()) {
13028
12946
  // if right is a constant, whatever side effects the
@@ -13413,7 +13331,7 @@
13413
13331
  // "x" + (y + "z")==> "x" + y + "z"
13414
13332
  if (self.right instanceof AST_Binary
13415
13333
  && self.right.operator == self.operator
13416
- && (lazy_op(self.operator)
13334
+ && (lazy_op.has(self.operator)
13417
13335
  || (self.operator == "+"
13418
13336
  && (self.right.left.is_string(compressor)
13419
13337
  || (self.left.is_string(compressor)
@@ -13682,8 +13600,8 @@
13682
13600
  return reachable;
13683
13601
  }
13684
13602
 
13685
- var ASSIGN_OPS = [ "+", "-", "/", "*", "%", ">>", "<<", ">>>", "|", "^", "&" ];
13686
- var ASSIGN_OPS_COMMUTATIVE = [ "*", "|", "^", "&" ];
13603
+ const ASSIGN_OPS = makePredicate("+ - / * % >> << >>> | ^ &");
13604
+ const ASSIGN_OPS_COMMUTATIVE = makePredicate("* | ^ &");
13687
13605
  def_optimize(AST_Assign, function(self, compressor) {
13688
13606
  var def;
13689
13607
  if (compressor.option("dead_code")
@@ -13712,13 +13630,13 @@
13712
13630
  // x = expr1 OP expr2
13713
13631
  if (self.right.left instanceof AST_SymbolRef
13714
13632
  && self.right.left.name == self.left.name
13715
- && member(self.right.operator, ASSIGN_OPS)) {
13633
+ && ASSIGN_OPS.has(self.right.operator)) {
13716
13634
  // x = x - 2 ---> x -= 2
13717
13635
  self.operator = self.right.operator + "=";
13718
13636
  self.right = self.right.right;
13719
13637
  } else if (self.right.right instanceof AST_SymbolRef
13720
13638
  && self.right.right.name == self.left.name
13721
- && member(self.right.operator, ASSIGN_OPS_COMMUTATIVE)
13639
+ && ASSIGN_OPS_COMMUTATIVE.has(self.right.operator)
13722
13640
  && !self.right.left.has_side_effects(compressor)) {
13723
13641
  // x = 2 & x ---> x &= 2
13724
13642
  self.operator = self.right.operator + "=";
@@ -14035,7 +13953,8 @@
14035
13953
  && property.length <= prop.print_to_string().length + 1) {
14036
13954
  return make_node(AST_Dot, self, {
14037
13955
  expression: expr,
14038
- property: property
13956
+ property: property,
13957
+ quote: prop.quote,
14039
13958
  }).optimize(compressor);
14040
13959
  }
14041
13960
  }
@@ -14050,17 +13969,17 @@
14050
13969
  && !(fn instanceof AST_Arrow)
14051
13970
  && prop instanceof AST_Number) {
14052
13971
  var index = prop.getValue();
14053
- var params = Object.create(null);
13972
+ var params = new Set();
14054
13973
  var argnames = fn.argnames;
14055
13974
  for (var n = 0; n < argnames.length; n++) {
14056
13975
  if (!(argnames[n] instanceof AST_SymbolFunarg)) {
14057
13976
  break OPT_ARGUMENTS; // destructuring parameter - bail
14058
13977
  }
14059
13978
  var param = argnames[n].name;
14060
- if (param in params) {
13979
+ if (params.has(param)) {
14061
13980
  break OPT_ARGUMENTS; // duplicate parameter - bail
14062
13981
  }
14063
- params[param] = true;
13982
+ params.add(param);
14064
13983
  }
14065
13984
  var argname = fn.argnames[index];
14066
13985
  if (argname && compressor.has_directive("use strict")) {
@@ -20356,14 +20275,14 @@
20356
20275
  var cache;
20357
20276
  if (options.cache) {
20358
20277
  cache = options.cache.props;
20359
- cache.each(function(mangled_name) {
20278
+ cache.forEach(function(mangled_name) {
20360
20279
  reserved.add(mangled_name);
20361
20280
  });
20362
20281
  } else {
20363
- cache = new Dictionary();
20282
+ cache = new Map();
20364
20283
  }
20365
20284
 
20366
- var regex = options.regex;
20285
+ var regex = options.regex && new RegExp(options.regex);
20367
20286
 
20368
20287
  // note debug is either false (disabled), or a string of the debug suffix to use (enabled).
20369
20288
  // note debug may be enabled as an empty string, which is falsey. Also treat passing 'true'
@@ -20377,23 +20296,33 @@
20377
20296
  var names_to_mangle = new Set();
20378
20297
  var unmangleable = new Set();
20379
20298
 
20299
+ var keep_quoted_strict = options.keep_quoted === "strict";
20300
+
20380
20301
  // step 1: find candidates to mangle
20381
20302
  ast.walk(new TreeWalker(function(node) {
20382
20303
  if (node instanceof AST_ObjectKeyVal) {
20383
- if (typeof node.key == "string") {
20304
+ if (typeof node.key == "string" &&
20305
+ (!keep_quoted_strict || !node.quote)) {
20384
20306
  add(node.key);
20385
20307
  }
20386
20308
  } else if (node instanceof AST_ObjectProperty) {
20387
20309
  // setter or getter, since KeyVal is handled above
20388
- add(node.key.name);
20310
+ if (!keep_quoted_strict || !node.key.end.quote) {
20311
+ add(node.key.name);
20312
+ }
20389
20313
  } else if (node instanceof AST_Dot) {
20390
20314
  var root = node;
20391
20315
  while (root.expression) {
20392
20316
  root = root.expression;
20393
20317
  }
20394
- if (!(root.thedef && root.thedef.undeclared)) add(node.property);
20318
+ if (!(root.thedef && root.thedef.undeclared) &&
20319
+ (!keep_quoted_strict || !node.quote)) {
20320
+ add(node.property);
20321
+ }
20395
20322
  } else if (node instanceof AST_Sub) {
20396
- addStrings(node.property, add);
20323
+ if (!keep_quoted_strict) {
20324
+ addStrings(node.property, add);
20325
+ }
20397
20326
  } else if (node instanceof AST_Call
20398
20327
  && node.expression.print_to_string() == "Object.defineProperty") {
20399
20328
  addStrings(node.args[1], add);
@@ -20403,14 +20332,19 @@
20403
20332
  // step 2: transform the tree, renaming properties
20404
20333
  return ast.transform(new TreeTransformer(function(node) {
20405
20334
  if (node instanceof AST_ObjectKeyVal) {
20406
- if (typeof node.key == "string") {
20335
+ if (typeof node.key == "string" &&
20336
+ (!keep_quoted_strict || !node.quote)) {
20407
20337
  node.key = mangle(node.key);
20408
20338
  }
20409
20339
  } else if (node instanceof AST_ObjectProperty) {
20410
20340
  // setter or getter
20411
- node.key.name = mangle(node.key.name);
20341
+ if (!keep_quoted_strict || !node.key.end.quote) {
20342
+ node.key.name = mangle(node.key.name);
20343
+ }
20412
20344
  } else if (node instanceof AST_Dot) {
20413
- node.property = mangle(node.property);
20345
+ if (!keep_quoted_strict || !node.quote) {
20346
+ node.property = mangle(node.property);
20347
+ }
20414
20348
  } else if (!options.keep_quoted && node instanceof AST_Sub) {
20415
20349
  node.property = mangleStrings(node.property);
20416
20350
  } else if (node instanceof AST_Call
@@ -20521,15 +20455,15 @@
20521
20455
  function init_cache(cache) {
20522
20456
  if (!cache) return;
20523
20457
  if (!("props" in cache)) {
20524
- cache.props = new Dictionary();
20525
- } else if (!(cache.props instanceof Dictionary)) {
20526
- cache.props = Dictionary.fromObject(cache.props);
20458
+ cache.props = new Map();
20459
+ } else if (!(cache.props instanceof Map)) {
20460
+ cache.props = map_from_object(cache.props);
20527
20461
  }
20528
20462
  }
20529
20463
 
20530
20464
  function to_json(cache) {
20531
20465
  return {
20532
- props: cache.props.toObject()
20466
+ props: map_to_object(cache.props)
20533
20467
  };
20534
20468
  }
20535
20469
 
@@ -20639,7 +20573,7 @@
20639
20573
  }
20640
20574
  toplevel = options.parse.toplevel;
20641
20575
  }
20642
- if (quoted_props) {
20576
+ if (quoted_props && options.mangle.properties.keep_quoted !== "strict") {
20643
20577
  reserve_quoted_keys(toplevel, quoted_props);
20644
20578
  }
20645
20579
  if (options.wrap) {
@@ -20730,6 +20664,24 @@
20730
20664
  }
20731
20665
  }
20732
20666
 
20667
+ function default_options() {
20668
+ const defs = {};
20669
+
20670
+ Object.keys(infer_options({ 0: 0 })).forEach((component) => {
20671
+ const options = infer_options({
20672
+ [component]: {0: 0}
20673
+ });
20674
+
20675
+ if (options) defs[component] = options;
20676
+ });
20677
+ return defs;
20678
+ }
20679
+
20680
+ function infer_options(options) {
20681
+ var result = minify("", options);
20682
+ return result.error && result.error.defs;
20683
+ }
20684
+
20733
20685
  /***********************************************************************
20734
20686
 
20735
20687
  A JavaScript tokenizer / parser / beautifier / compressor.
@@ -21830,126 +21782,16 @@
21830
21782
  exports.TreeTransformer = TreeTransformer;
21831
21783
  exports.TreeWalker = TreeWalker;
21832
21784
  exports.defaults = defaults;
21833
- exports.Dictionary = Dictionary;
21834
21785
  exports.push_uniq = push_uniq;
21835
21786
  exports.string_template = string_template;
21836
21787
  exports.base54 = base54;
21837
21788
  exports.Compressor = Compressor;
21789
+ exports.to_ascii = to_ascii;
21838
21790
  exports.OutputStream = OutputStream;
21839
21791
  exports.parse = parse;
21840
21792
  exports.mangle_properties = mangle_properties;
21841
21793
  exports.reserve_quoted_keys = reserve_quoted_keys;
21842
- exports.JS_Parse_Error = JS_Parse_Error;
21843
- exports.tokenizer = tokenizer;
21844
- exports.to_ascii = to_ascii;
21845
- exports.AST_Accessor = AST_Accessor;
21846
- exports.AST_Arrow = AST_Arrow;
21847
- exports.AST_Atom = AST_Atom;
21848
- exports.AST_Await = AST_Await;
21849
- exports.AST_Binary = AST_Binary;
21850
- exports.AST_Block = AST_Block;
21851
- exports.AST_BlockStatement = AST_BlockStatement;
21852
- exports.AST_Boolean = AST_Boolean;
21853
- exports.AST_Break = AST_Break;
21854
- exports.AST_Call = AST_Call;
21855
- exports.AST_Case = AST_Case;
21856
- exports.AST_Catch = AST_Catch;
21857
- exports.AST_Class = AST_Class;
21858
- exports.AST_ClassExpression = AST_ClassExpression;
21859
- exports.AST_ConciseMethod = AST_ConciseMethod;
21860
- exports.AST_Conditional = AST_Conditional;
21861
- exports.AST_Const = AST_Const;
21862
- exports.AST_Continue = AST_Continue;
21863
- exports.AST_Debugger = AST_Debugger;
21864
- exports.AST_Default = AST_Default;
21865
- exports.AST_DefaultAssign = AST_DefaultAssign;
21866
- exports.AST_DefClass = AST_DefClass;
21867
- exports.AST_Definitions = AST_Definitions;
21868
- exports.AST_Defun = AST_Defun;
21869
- exports.AST_Destructuring = AST_Destructuring;
21870
- exports.AST_Directive = AST_Directive;
21871
- exports.AST_Do = AST_Do;
21872
- exports.AST_Dot = AST_Dot;
21873
- exports.AST_DWLoop = AST_DWLoop;
21874
- exports.AST_EmptyStatement = AST_EmptyStatement;
21875
- exports.AST_Exit = AST_Exit;
21876
- exports.AST_Expansion = AST_Expansion;
21877
- exports.AST_Export = AST_Export;
21878
- exports.AST_False = AST_False;
21879
- exports.AST_Finally = AST_Finally;
21880
- exports.AST_For = AST_For;
21881
- exports.AST_ForIn = AST_ForIn;
21882
- exports.AST_ForOf = AST_ForOf;
21883
- exports.AST_Function = AST_Function;
21884
- exports.AST_Hole = AST_Hole;
21885
- exports.AST_If = AST_If;
21886
- exports.AST_Import = AST_Import;
21887
- exports.AST_Infinity = AST_Infinity;
21888
- exports.AST_IterationStatement = AST_IterationStatement;
21889
- exports.AST_Jump = AST_Jump;
21890
- exports.AST_Label = AST_Label;
21891
- exports.AST_LabeledStatement = AST_LabeledStatement;
21892
- exports.AST_LabelRef = AST_LabelRef;
21893
- exports.AST_Lambda = AST_Lambda;
21894
- exports.AST_Let = AST_Let;
21895
- exports.AST_LoopControl = AST_LoopControl;
21896
- exports.AST_NameMapping = AST_NameMapping;
21897
- exports.AST_NaN = AST_NaN;
21898
- exports.AST_New = AST_New;
21899
- exports.AST_NewTarget = AST_NewTarget;
21900
- exports.AST_Null = AST_Null;
21901
- exports.AST_Number = AST_Number;
21902
- exports.AST_Object = AST_Object;
21903
- exports.AST_ObjectGetter = AST_ObjectGetter;
21904
- exports.AST_ObjectKeyVal = AST_ObjectKeyVal;
21905
- exports.AST_ObjectProperty = AST_ObjectProperty;
21906
- exports.AST_ObjectSetter = AST_ObjectSetter;
21907
- exports.AST_PrefixedTemplateString = AST_PrefixedTemplateString;
21908
- exports.AST_RegExp = AST_RegExp;
21909
- exports.AST_Return = AST_Return;
21910
- exports.AST_Scope = AST_Scope;
21911
- exports.AST_SimpleStatement = AST_SimpleStatement;
21912
- exports.AST_Statement = AST_Statement;
21913
- exports.AST_StatementWithBody = AST_StatementWithBody;
21914
- exports.AST_String = AST_String;
21915
- exports.AST_Sub = AST_Sub;
21916
- exports.AST_Super = AST_Super;
21917
- exports.AST_Switch = AST_Switch;
21918
- exports.AST_SwitchBranch = AST_SwitchBranch;
21919
- exports.AST_SymbolBlockDeclaration = AST_SymbolBlockDeclaration;
21920
- exports.AST_SymbolCatch = AST_SymbolCatch;
21921
- exports.AST_SymbolClass = AST_SymbolClass;
21922
- exports.AST_SymbolConst = AST_SymbolConst;
21923
- exports.AST_SymbolDeclaration = AST_SymbolDeclaration;
21924
- exports.AST_SymbolDefClass = AST_SymbolDefClass;
21925
- exports.AST_SymbolDefun = AST_SymbolDefun;
21926
- exports.AST_SymbolExport = AST_SymbolExport;
21927
- exports.AST_SymbolExportForeign = AST_SymbolExportForeign;
21928
- exports.AST_SymbolFunarg = AST_SymbolFunarg;
21929
- exports.AST_SymbolImport = AST_SymbolImport;
21930
- exports.AST_SymbolImportForeign = AST_SymbolImportForeign;
21931
- exports.AST_SymbolLambda = AST_SymbolLambda;
21932
- exports.AST_SymbolLet = AST_SymbolLet;
21933
- exports.AST_SymbolMethod = AST_SymbolMethod;
21934
- exports.AST_SymbolRef = AST_SymbolRef;
21935
- exports.AST_SymbolVar = AST_SymbolVar;
21936
- exports.AST_TemplateSegment = AST_TemplateSegment;
21937
- exports.AST_TemplateString = AST_TemplateString;
21938
- exports.AST_This = AST_This;
21939
- exports.AST_Throw = AST_Throw;
21940
- exports.AST_Toplevel = AST_Toplevel;
21941
- exports.AST_True = AST_True;
21942
- exports.AST_Try = AST_Try;
21943
- exports.AST_Unary = AST_Unary;
21944
- exports.AST_UnaryPostfix = AST_UnaryPostfix;
21945
- exports.AST_UnaryPrefix = AST_UnaryPrefix;
21946
- exports.AST_Undefined = AST_Undefined;
21947
- exports.AST_Var = AST_Var;
21948
- exports.AST_VarDef = AST_VarDef;
21949
- exports.AST_While = AST_While;
21950
- exports.AST_With = AST_With;
21951
- exports.AST_Yield = AST_Yield;
21952
- exports.walk_body = walk_body;
21794
+ exports.default_options = default_options;
21953
21795
 
21954
21796
  }));
21955
21797
  //# sourceMappingURL=bundle.js.map