@@ -106,10 +106,16 @@ function Compressor(options, false_by_default) {
|
|||||||
var pure_funcs = this.options["pure_funcs"];
|
var pure_funcs = this.options["pure_funcs"];
|
||||||
if (typeof pure_funcs == "function") {
|
if (typeof pure_funcs == "function") {
|
||||||
this.pure_funcs = pure_funcs;
|
this.pure_funcs = pure_funcs;
|
||||||
} else {
|
} else if (typeof pure_funcs == "string") {
|
||||||
this.pure_funcs = pure_funcs ? function(node) {
|
this.pure_funcs = function(node) {
|
||||||
|
return pure_funcs !== node.expression.print_to_string();
|
||||||
|
};
|
||||||
|
} else if (Array.isArray(pure_funcs)) {
|
||||||
|
this.pure_funcs = function(node) {
|
||||||
return pure_funcs.indexOf(node.expression.print_to_string()) < 0;
|
return pure_funcs.indexOf(node.expression.print_to_string()) < 0;
|
||||||
} : return_true;
|
};
|
||||||
|
} else {
|
||||||
|
this.pure_funcs = return_true;
|
||||||
}
|
}
|
||||||
var top_retain = this.options["top_retain"];
|
var top_retain = this.options["top_retain"];
|
||||||
if (top_retain instanceof RegExp) {
|
if (top_retain instanceof RegExp) {
|
||||||
|
|||||||
@@ -642,3 +642,41 @@ issue_3065_4: {
|
|||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_3325_1: {
|
||||||
|
options = {
|
||||||
|
pure_funcs: "cb",
|
||||||
|
side_effects: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function cb() {
|
||||||
|
console.log("PASS");
|
||||||
|
}
|
||||||
|
cb();
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
function cb() {
|
||||||
|
console.log("PASS");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_3325_2: {
|
||||||
|
options = {
|
||||||
|
pure_funcs: "xxxcbxxx",
|
||||||
|
side_effects: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function cb() {
|
||||||
|
console.log("PASS");
|
||||||
|
}
|
||||||
|
cb();
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
function cb() {
|
||||||
|
console.log("PASS");
|
||||||
|
}
|
||||||
|
cb();
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user