Fixed wrong generation of code that has statements after ReturnStatment when simplify option is enabled

This commit is contained in:
Timofey Kachalov
2022-02-06 21:10:16 +03:00
committed by GitHub
parent 40eec6185c
commit 77f64bf5df
17 changed files with 311 additions and 49 deletions
+10 -27
View File
@@ -1,43 +1,26 @@
'use strict';
import { StringArrayWrappersType } from '../../src/enums/node-transformers/string-array-transformers/StringArrayWrappersType';
(function () {
const JavaScriptObfuscator: any = require('../../index');
let obfuscatedCode: string = JavaScriptObfuscator.obfuscate(
`
function foo () {
var bar = 'bar';
function baz () {
var baz = 'baz';
return baz;
async function xyzzy(a,b)
{
if (a) {
return await foo(a) ;
console.log(a) ;
} else {
return await bar(b) ;
console.log(b) ;
}
return bar + baz();
}
console.log(foo());
`,
{
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
simplify: true,
stringArray: false
}
).getObfuscatedCode();