mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
refactoring
This commit is contained in:
+4
-4
@@ -17,15 +17,15 @@ export class Utils {
|
||||
* @param array
|
||||
* @param times
|
||||
* @param reverse
|
||||
* @returns any[]
|
||||
* @returns {T[]}
|
||||
*/
|
||||
public static arrayRotate (array: any[], times: number, reverse: boolean = false): any[] {
|
||||
public static arrayRotate <T> (array: T[], times: number, reverse: boolean = false): T[] {
|
||||
if (times < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
let newArray: any[] = array,
|
||||
temp: any;
|
||||
let newArray: T[] = array,
|
||||
temp: T;
|
||||
|
||||
while (times--) {
|
||||
if (!reverse) {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import * as esprima from 'esprima';
|
||||
|
||||
import { INode } from "../../interfaces/nodes/INode";
|
||||
|
||||
import { TBlockScopeNode } from "../../types/TBlockScopeNode";
|
||||
|
||||
import { Node } from '../Node';
|
||||
@@ -33,9 +35,9 @@ export class ConsoleOutputDisableExpressionNode extends Node {
|
||||
* _console
|
||||
* })();
|
||||
*
|
||||
* @returns any
|
||||
* @returns {INode}
|
||||
*/
|
||||
protected getNodeStructure (): any {
|
||||
protected getNodeStructure (): INode {
|
||||
return NodeUtils.getBlockScopeNodeByIndex(
|
||||
esprima.parse(`
|
||||
(function () {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { IExpressionStatementNode } from "../../interfaces/nodes/IExpressionStatementNode";
|
||||
|
||||
import { TBlockScopeNode } from "../../types/TBlockScopeNode";
|
||||
|
||||
import { NodeType } from "../../enums/NodeType";
|
||||
@@ -30,9 +32,9 @@ export class DebugProtectionFunctionCallNode extends Node {
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns any
|
||||
* @returns {IExpressionStatementNode}
|
||||
*/
|
||||
protected getNodeStructure (): any {
|
||||
protected getNodeStructure (): IExpressionStatementNode {
|
||||
return {
|
||||
'type': NodeType.ExpressionStatement,
|
||||
'expression': {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { IExpressionStatementNode } from "../../interfaces/nodes/IExpressionStatementNode";
|
||||
|
||||
import { TBlockScopeNode } from "../../types/TBlockScopeNode";
|
||||
|
||||
import { NodeType } from '../../enums/NodeType';
|
||||
@@ -30,9 +32,9 @@ export class DebugProtectionFunctionIntervalNode extends Node {
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns any
|
||||
* @returns {IExpressionStatementNode}
|
||||
*/
|
||||
protected getNodeStructure (): any {
|
||||
protected getNodeStructure (): IExpressionStatementNode {
|
||||
return {
|
||||
'type': NodeType.ExpressionStatement,
|
||||
'expression': {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import * as esprima from 'esprima';
|
||||
|
||||
import { INode } from "../../interfaces/nodes/INode";
|
||||
|
||||
import { TBlockScopeNode } from "../../types/TBlockScopeNode";
|
||||
|
||||
import { Node } from '../Node';
|
||||
@@ -45,9 +47,9 @@ export class DebugProtectionFunctionNode extends Node {
|
||||
/**
|
||||
* Found this trick in JScrambler
|
||||
*
|
||||
* @returns any
|
||||
* @returns {INode}
|
||||
*/
|
||||
protected getNodeStructure (): any {
|
||||
protected getNodeStructure (): INode {
|
||||
return NodeUtils.getBlockScopeNodeByIndex(
|
||||
esprima.parse(`
|
||||
var ${this.debugProtectionFunctionName} = function () {
|
||||
|
||||
@@ -76,9 +76,9 @@ export class UnicodeArrayCallsWrapper extends Node {
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns any
|
||||
* @returns {INode}
|
||||
*/
|
||||
protected getNodeStructure (): any {
|
||||
protected getNodeStructure (): INode {
|
||||
let keyName: string = Utils.getRandomVariableName(),
|
||||
node: INode = esprima.parse(`
|
||||
var ${this.unicodeArrayCallsWrapperName} = function (${keyName}) {
|
||||
|
||||
@@ -10,6 +10,7 @@ import { NodeType } from "../../enums/NodeType";
|
||||
import { Node } from '../Node';
|
||||
import { NodeUtils } from "../../NodeUtils";
|
||||
import { Utils } from '../../Utils';
|
||||
import {IVariableDeclarationNode} from "../../interfaces/nodes/IVariableDeclarationNode";
|
||||
|
||||
export class UnicodeArrayNode extends Node {
|
||||
/**
|
||||
@@ -79,7 +80,7 @@ export class UnicodeArrayNode extends Node {
|
||||
return;
|
||||
}
|
||||
|
||||
Utils.arrayRotate(this.unicodeArray, this.unicodeArrayRotateValue);
|
||||
Utils.arrayRotate <string> (this.unicodeArray, this.unicodeArrayRotateValue);
|
||||
|
||||
this.updateNode();
|
||||
|
||||
@@ -87,9 +88,9 @@ export class UnicodeArrayNode extends Node {
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns any
|
||||
* @returns {INode}
|
||||
*/
|
||||
protected getNodeStructure (): any {
|
||||
protected getNodeStructure (): IVariableDeclarationNode {
|
||||
return {
|
||||
'type': NodeType.VariableDeclaration,
|
||||
'declarations': [
|
||||
|
||||
@@ -69,9 +69,9 @@ export class UnicodeArrayRotateFunctionNode extends Node {
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns any
|
||||
* @returns {INode}
|
||||
*/
|
||||
protected getNodeStructure (): any {
|
||||
protected getNodeStructure (): INode {
|
||||
let arrayName: string = Utils.getRandomVariableName(),
|
||||
timesName: string = Utils.getRandomVariableName(),
|
||||
tempArrayName: string = Utils.getRandomVariableName(),
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
import { INode } from "./INode";
|
||||
|
||||
export interface IExpressionStatementNode extends INode {
|
||||
expression: any;
|
||||
}
|
||||
Reference in New Issue
Block a user