anobis
Version:
JavaScript obfuscator
68 lines (54 loc) • 2.11 kB
text/typescript
import { injectable, inject } from 'inversify';
import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
import * as format from 'string-template';
import { TStatement } from '../../types/node/TStatement';
import { IOptions } from '../../interfaces/options/IOptions';
import { IRandomGenerator } from '../../interfaces/utils/IRandomGenerator';
import { ConsoleOutputDisableExpressionTemplate } from '../../templates/custom-nodes/console-output-nodes/console-output-disable-expression-node/ConsoleOutputDisableExpressionTemplate';
import { initializable } from '../../decorators/Initializable';
import { AbstractCustomNode } from '../AbstractCustomNode';
import { NodeUtils } from '../../node/NodeUtils';
()
export class ConsoleOutputDisableExpressionNode extends AbstractCustomNode {
/**
* @type {string}
*/
()
private callsControllerFunctionName: string;
/**
* @type {IRandomGenerator}
*/
private readonly randomGenerator: IRandomGenerator;
/**
* @param {IRandomGenerator} randomGenerator
* @param {IOptions} options
*/
constructor (
(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
(ServiceIdentifiers.IOptions) options: IOptions
) {
super(options);
this.randomGenerator = randomGenerator;
}
/**
* @param {string} callsControllerFunctionName
*/
public initialize (callsControllerFunctionName: string): void {
this.callsControllerFunctionName = callsControllerFunctionName;
}
/**
* @returns {TStatement[]}
*/
protected getNodeStructure (): TStatement[] {
return NodeUtils.convertCodeToStructure(this.getTemplate());
}
/**
* @returns {string}
*/
protected getTemplate (): string {
return format(ConsoleOutputDisableExpressionTemplate(), {
consoleLogDisableFunctionName: this.randomGenerator.getRandomVariableName(6),
singleNodeCallControllerFunctionName: this.callsControllerFunctionName
});
}
}