diff --git a/index.ts b/index.ts index 43744b51..dc32fc67 100644 --- a/index.ts +++ b/index.ts @@ -28,14 +28,21 @@ export class JavaScriptObfuscator { obfuscator.obfuscateNode(astTree); - return JavaScriptObfuscator.generateCode(astTree); + return JavaScriptObfuscator.generateCode(astTree, options); } /** * @param astTree + * @param options */ - private static generateCode (astTree: any): string { - return escodegen.generate(astTree, JavaScriptObfuscator.escodegenParams); + private static generateCode (astTree: any, options: any): string { + let escodegenParams: any = Object.assign({}, JavaScriptObfuscator.escodegenParams); + + if (options.compact !== undefined) { + escodegenParams.format.compact = options.compact; + } + + return escodegen.generate(astTree, escodegenParams); } }