Add --mangle-regex option

This commit is contained in:
Joao Carlos
2015-06-09 13:21:22 +03:00
parent c6fa291571
commit 0ac6918a41
3 changed files with 14 additions and 2 deletions

View File

@@ -64,7 +64,8 @@ function mangle_properties(ast, options) {
options = defaults(options, {
reserved : null,
cache : null,
only_cache : false
only_cache : false,
regex : null
});
var reserved = options.reserved;
@@ -79,6 +80,8 @@ function mangle_properties(ast, options) {
};
}
var regex = options.regex;
var names_to_mangle = [];
// step 1: find candidates to mangle
@@ -149,6 +152,7 @@ function mangle_properties(ast, options) {
}
function should_mangle(name) {
if (regex && !regex.test(name)) return false;
if (reserved.indexOf(name) >= 0) return false;
return cache.props.has(name)
|| names_to_mangle.indexOf(name) >= 0;