terser 5.3.3 → 5.3.4

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.
@@ -4140,9 +4140,12 @@ AST_Scope.DEFMETHOD("hoist_declarations", function(compressor) {
4140
4140
  hoisted.push(node);
4141
4141
  return make_node(AST_EmptyStatement, node);
4142
4142
  }
4143
- if (hoist_vars && node instanceof AST_Var) {
4143
+ if (
4144
+ hoist_vars
4145
+ && node instanceof AST_Var
4146
+ && !node.definitions.some(def => def.name instanceof AST_Destructuring)
4147
+ ) {
4144
4148
  node.definitions.forEach(function(def) {
4145
- if (def.name instanceof AST_Destructuring) return;
4146
4149
  vars.set(def.name.name, def);
4147
4150
  ++vars_found;
4148
4151
  });
@@ -4222,8 +4225,7 @@ AST_Scope.DEFMETHOD("hoist_declarations", function(compressor) {
4222
4225
  continue;
4223
4226
  }
4224
4227
  if (self.body[i] instanceof AST_BlockStatement) {
4225
- var tmp = [ i, 1 ].concat(self.body[i].body);
4226
- self.body.splice.apply(self.body, tmp);
4228
+ self.body.splice(i, 1, ...self.body[i].body);
4227
4229
  continue;
4228
4230
  }
4229
4231
  break;
@@ -4969,10 +4971,12 @@ AST_Definitions.DEFMETHOD("remove_initializers", function() {
4969
4971
 
4970
4972
  AST_Definitions.DEFMETHOD("to_assignments", function(compressor) {
4971
4973
  var reduce_vars = compressor.option("reduce_vars");
4972
- var assignments = this.definitions.reduce(function(a, def) {
4973
- if (def.value && !(def.name instanceof AST_Destructuring)) {
4974
+ var assignments = [];
4975
+
4976
+ for (const def of this.definitions) {
4977
+ if (def.value) {
4974
4978
  var name = make_node(AST_SymbolRef, def.name, def.name);
4975
- a.push(make_node(AST_Assign, def, {
4979
+ assignments.push(make_node(AST_Assign, def, {
4976
4980
  operator : "=",
4977
4981
  left : name,
4978
4982
  right : def.value
@@ -4987,13 +4991,13 @@ AST_Definitions.DEFMETHOD("to_assignments", function(compressor) {
4987
4991
  var var_ = make_node(AST_Var, def, {
4988
4992
  definitions: [ varDef ]
4989
4993
  });
4990
- a.push(var_);
4994
+ assignments.push(var_);
4991
4995
  }
4992
- def = def.name.definition();
4993
- def.eliminated++;
4994
- def.replaced--;
4995
- return a;
4996
- }, []);
4996
+ const thedef = def.name.definition();
4997
+ thedef.eliminated++;
4998
+ thedef.replaced--;
4999
+ }
5000
+
4997
5001
  if (assignments.length == 0) return null;
4998
5002
  return make_sequence(this, assignments);
4999
5003
  });
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "homepage": "https://terser.org",
5
5
  "author": "Mihai Bazon <mihai.bazon@gmail.com> (http://lisperator.net/)",
6
6
  "license": "BSD-2-Clause",
7
- "version": "5.3.3",
7
+ "version": "5.3.4",
8
8
  "engines": {
9
9
  "node": ">=6.0.0"
10
10
  },