Sign In

terser

Package Overview
Dependencies
Maintainers
1
Versions
207
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

terser - npm Package Compare versions

Comparing version
5.46.0
to
5.46.1
+6
-0
CHANGELOG.md
# Changelog
## v5.46.1
- Fix extremely slow (seemed like a freeze) `evaluate` of method chains
- Parse extremely large floating-point number literals as `Infinity`
- Remove parens from comma expressions in computed property access (`foo[(1, 2)]`)
## v5.46.0

@@ -4,0 +10,0 @@

+24
-17

@@ -374,2 +374,11 @@ /***********************************************************************

def_eval(AST_Chain, function (compressor, depth) {
const evaluated = this.expression._eval(compressor, depth, /*ast_chain=*/true);
return evaluated === nullish
? undefined
: evaluated === this.expression
? this
: evaluated;
});
const global_objs = { Array, Math, Number, Object, String };

@@ -386,6 +395,10 @@

def_eval(AST_PropAccess, function (compressor, depth) {
let obj = this.expression._eval(compressor, depth + 1);
if (obj === nullish || (this.optional && obj == null)) return nullish;
def_eval(AST_PropAccess, function (compressor, depth, ast_chain) {
let obj = (ast_chain || this.property === "length" || compressor.option("unsafe"))
&& this.expression._eval(compressor, depth + 1, ast_chain);
if (ast_chain) {
if (obj === nullish || (this.optional && obj == null)) return nullish;
}
// `.length` of strings and arrays is always safe

@@ -460,16 +473,9 @@ if (this.property === "length") {

def_eval(AST_Chain, function (compressor, depth) {
const evaluated = this.expression._eval(compressor, depth);
return evaluated === nullish
? undefined
: evaluated === this.expression
? this
: evaluated;
});
def_eval(AST_Call, function (compressor, depth) {
def_eval(AST_Call, function (compressor, depth, ast_chain) {
var exp = this.expression;
const callee = exp._eval(compressor, depth);
if (callee === nullish || (this.optional && callee == null)) return nullish;
if (ast_chain) {
const callee = exp._eval(compressor, depth, ast_chain);
if (callee === nullish || (this.optional && callee == null)) return nullish;
}

@@ -480,3 +486,3 @@ if (compressor.option("unsafe") && exp instanceof AST_PropAccess) {

key = key._eval(compressor, depth);
if (key === exp.property)
if (typeof key !== "string" && typeof key !== "number")
return this;

@@ -499,3 +505,4 @@ }

} else {
val = e._eval(compressor, depth + 1);
val = e._eval(compressor, depth + 1, /* don't pass ast_chain (exponential work) */);
if (val === e || !val)

@@ -502,0 +509,0 @@ return this;

@@ -961,6 +961,9 @@ /***********************************************************************

var expr = this.expression;
var first_arg = (this.args && this.args[0] && this.args[0].evaluate(compressor));
var first_arg;
if (
expr.expression && expr.expression.name === "hasOwnProperty" &&
(first_arg == null || first_arg.thedef && first_arg.thedef.undeclared)
(
(first_arg = (this.args && this.args[0] && this.args[0].evaluate(compressor))) == null
|| first_arg.thedef && first_arg.thedef.undeclared
)
) {

@@ -967,0 +970,0 @@ return false;

@@ -7,3 +7,3 @@ {

"license": "BSD-2-Clause",
"version": "5.46.0",
"version": "5.46.1",
"engines": {

@@ -10,0 +10,0 @@ "node": ">=10"

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display