Added stringArrayCallsTransform and stringArrayCallsTransformThreshold options (#987)

This commit is contained in:
Timofey Kachalov
2022-02-05 20:57:39 +03:00
committed by GitHub
parent 7307b02712
commit f075a0e2d1
78 changed files with 1758 additions and 332 deletions
+36 -12
View File
@@ -1,22 +1,46 @@
'use strict';
import { StringArrayWrappersType } from '../../src/enums/node-transformers/string-array-transformers/StringArrayWrappersType';
(function () {
const JavaScriptObfuscator: any = require('../../index');
const code: string = `
class Foo {}
`;
let obfuscationResult = JavaScriptObfuscator.obfuscate(
code,
let obfuscatedCode: string = JavaScriptObfuscator.obfuscate(
`
function foo () {
var bar = 'bar';
function baz () {
var baz = 'baz';
return baz;
}
return bar + baz();
}
console.log(foo());
`,
{
compact: false
identifierNamesGenerator: 'mangled',
compact: false,
controlFlowFlattening: true,
controlFlowFlatteningThreshold: 1,
simplify: false,
stringArray: true,
stringArrayIndexesType: [
'hexadecimal-number',
'hexadecimal-numeric-string'
],
stringArrayThreshold: 1,
stringArrayCallsTransform: true,
stringArrayCallsTransformThreshold: 1,
rotateStringArray: true,
stringArrayWrappersType: StringArrayWrappersType.Function,
transformObjectKeys: true
}
);
let obfuscatedCode: string = obfuscationResult.getObfuscatedCode();
let identifierNamesCache = obfuscationResult.getIdentifierNamesCache();
).getObfuscatedCode();
console.log(obfuscatedCode);
console.log(eval(obfuscatedCode));
console.log(identifierNamesCache);
})();
})();