Jelajahi Sumber

refactoring

sanex3339 9 tahun lalu
induk
melakukan
c23e70de32

+ 4 - 4
src/Utils.ts

@@ -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) {

+ 4 - 2
src/custom-nodes/console-output-nodes/ConsoleOutputDisableExpressionNode.ts

@@ -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 () {

+ 4 - 2
src/custom-nodes/debug-protection-nodes/DebugProtectionFunctionCallNode.ts

@@ -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': {

+ 4 - 2
src/custom-nodes/debug-protection-nodes/DebugProtectionFunctionIntervalNode.ts

@@ -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': {

+ 4 - 2
src/custom-nodes/debug-protection-nodes/DebugProtectionFunctionNode.ts

@@ -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 () {

+ 2 - 2
src/custom-nodes/unicode-array-nodes/UnicodeArrayCallsWrapper.ts

@@ -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}) {

+ 4 - 3
src/custom-nodes/unicode-array-nodes/UnicodeArrayNode.ts

@@ -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': [

+ 2 - 2
src/custom-nodes/unicode-array-nodes/UnicodeArrayRotateFunctionNode.ts

@@ -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(),

+ 5 - 0
src/interfaces/nodes/IExpressionStatementNode.d.ts

@@ -0,0 +1,5 @@
+import { INode } from "./INode";
+
+export interface IExpressionStatementNode extends INode {
+    expression: any;
+}