mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
test
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
"use strict";
|
||||
|
||||
import kernel from "./Kernel";
|
||||
|
||||
import * as esprima from 'esprima';
|
||||
import * as escodegen from 'escodegen';
|
||||
|
||||
@@ -10,6 +8,9 @@ import { IObfuscator } from "./interfaces/IObfuscator";
|
||||
import { IOptions } from './interfaces/IOptions';
|
||||
import { IOptionsPreset } from "./interfaces/IOptionsPreset";
|
||||
|
||||
import { Obfuscator } from "./Obfuscator";
|
||||
import { Options } from "./Options";
|
||||
|
||||
export class JavaScriptObfuscator {
|
||||
/**
|
||||
* @type {GenerateOptions}
|
||||
@@ -24,10 +25,8 @@ export class JavaScriptObfuscator {
|
||||
*/
|
||||
public static obfuscate (sourceCode: string, customOptions?: IOptionsPreset): string {
|
||||
let astTree: INode = esprima.parse(sourceCode),
|
||||
options: IOptions = kernel.get<IOptions>('IOptions'),
|
||||
obfuscator: IObfuscator = kernel.get<IObfuscator>('IObfuscator');
|
||||
|
||||
options.assign(customOptions);
|
||||
options: IOptions = new Options(customOptions),
|
||||
obfuscator: IObfuscator = new Obfuscator(options);
|
||||
|
||||
astTree = obfuscator.obfuscateNode(astTree);
|
||||
|
||||
@@ -42,7 +41,7 @@ export class JavaScriptObfuscator {
|
||||
let escodegenParams: escodegen.GenerateOptions = Object.assign({}, JavaScriptObfuscator.escodegenParams);
|
||||
|
||||
escodegenParams.format = {
|
||||
compact: options.getOption('compact')
|
||||
compact: options.get<boolean>('compact')
|
||||
};
|
||||
|
||||
return escodegen.generate(astTree, escodegenParams);
|
||||
|
||||
Reference in New Issue
Block a user