Kaynağa Gözat

Some refactoring

sanex3339 7 yıl önce
ebeveyn
işleme
4b74976cc7
86 değiştirilmiş dosya ile 832 ekleme ve 936 silme
  1. 0 0
      dist/index.browser.js
  2. 0 0
      dist/index.cli.js
  3. 0 0
      dist/index.js
  4. 2 2
      src/custom-nodes/console-output-nodes/group/ConsoleOutputCustomNodeGroup.ts
  5. 1 1
      src/custom-nodes/control-flow-flattening-nodes/BinaryExpressionFunctionNode.ts
  6. 1 1
      src/custom-nodes/control-flow-flattening-nodes/BlockStatementControlFlowFlatteningNode.ts
  7. 1 1
      src/custom-nodes/control-flow-flattening-nodes/CallExpressionFunctionNode.ts
  8. 1 1
      src/custom-nodes/control-flow-flattening-nodes/LogicalExpressionFunctionNode.ts
  9. 1 1
      src/custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/CallExpressionControlFlowStorageCallNode.ts
  10. 1 1
      src/custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/ControlFlowStorageNode.ts
  11. 1 1
      src/custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/ExpressionWithOperatorControlFlowStorageCallNode.ts
  12. 1 1
      src/custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/StringLiteralControlFlowStorageCallNode.ts
  13. 1 1
      src/custom-nodes/dead-code-injection-nodes/BlockStatementDeadCodeInjectionNode.ts
  14. 4 4
      src/custom-nodes/debug-protection-nodes/group/DebugProtectionCustomNodeGroup.ts
  15. 2 2
      src/custom-nodes/domain-lock-nodes/group/DomainLockCustomNodeGroup.ts
  16. 2 2
      src/custom-nodes/self-defending-nodes/group/SelfDefendingCustomNodeGroup.ts
  17. 2 2
      src/custom-nodes/string-array-nodes/StringArrayRotateFunctionNode.ts
  18. 3 3
      src/custom-nodes/string-array-nodes/group/StringArrayCustomNodeGroup.ts
  19. 3 3
      src/generators/identifier-names-generators/AbstractIdentifierNamesGenerator.ts
  20. 2 1
      src/generators/identifier-names-generators/HexadecimalIdentifierNamesGenerator.ts
  21. 3 3
      src/interfaces/utils/IArrayUtils.d.ts
  22. 2 2
      src/node-transformers/control-flow-transformers/BlockStatementControlFlowTransformer.ts
  23. 1 1
      src/node-transformers/control-flow-transformers/FunctionControlFlowTransformer.ts
  24. 99 133
      src/node-transformers/converting-transformers/ObjectExpressionKeysTransformer.ts
  25. 3 2
      src/node-transformers/obfuscating-transformers/obfuscating-replacers/literal-obfuscating-replacers/NumberLiteralObfuscatingReplacer.ts
  26. 2 1
      src/node-transformers/obfuscating-transformers/obfuscating-replacers/literal-obfuscating-replacers/StringLiteralObfuscatingReplacer.ts
  27. 65 64
      src/node/NodeAppender.ts
  28. 27 25
      src/node/NodeUtils.ts
  29. 21 19
      src/options/ValidationErrorsFormatter.ts
  30. 1 1
      src/options/normalizer-rules/DomainLockRule.ts
  31. 1 1
      src/storages/string-array/StringArrayStorage.ts
  32. 3 3
      src/utils/ArrayUtils.ts
  33. 19 0
      src/utils/NumberUtils.ts
  34. 1 51
      src/utils/Utils.ts
  35. 1 1
      test/functional-tests/analyzers/stack-trace-analyzer/StackTraceAnalyzer.spec.ts
  36. 1 1
      test/functional-tests/cli/JavaScriptObfuscatorCLI.spec.ts
  37. 1 1
      test/functional-tests/javascript-obfuscator/JavaScriptObfuscator.spec.ts
  38. 1 1
      test/functional-tests/node-transformers/control-flow-transformers/block-statement-control-flow-transformer/BlockStatementControlFlowTransformer.spec.ts
  39. 1 1
      test/functional-tests/node-transformers/control-flow-transformers/control-flow-replacers/binary-expression-control-flow-replacer/BinaryExpressionControlFlowReplacer.spec.ts
  40. 1 1
      test/functional-tests/node-transformers/control-flow-transformers/control-flow-replacers/call-expression-control-flow-replacer/CallExpressionControlFlowReplacer.spec.ts
  41. 1 1
      test/functional-tests/node-transformers/control-flow-transformers/control-flow-replacers/logical-expression-control-flow-replacer/LogicalExpressionControlFlowReplacer.spec.ts
  42. 1 1
      test/functional-tests/node-transformers/control-flow-transformers/control-flow-replacers/string-litertal-control-flow-replacer/StringLiteralControlFlowReplacer.spec.ts
  43. 1 1
      test/functional-tests/node-transformers/control-flow-transformers/function-control-flow-transformer/FunctionControlFlowTransformer.spec.ts
  44. 23 0
      test/functional-tests/node-transformers/converting-transformers/object-expression-keys-transformer/ObjectExpressionKeysTransformer.spec.ts
  45. 3 0
      test/functional-tests/node-transformers/converting-transformers/object-expression-keys-transformer/fixtures/empty-object-expression.js
  46. 1 1
      test/functional-tests/node-transformers/dead-code-injection-transformers/DeadCodeInjectionTransformer.spec.ts
  47. 1 1
      test/functional-tests/node-transformers/obfuscating-transformers/catch-clause-transformer/CatchClauseTransformer.spec.ts
  48. 1 1
      test/functional-tests/node-transformers/obfuscating-transformers/labeled-statement-transformer/LabeledStatementTransformer.spec.ts
  49. 1 1
      test/functional-tests/node-transformers/preparing-transformers/obfuscating-guards/black-list-obfuscating-guard/BlackListObfuscatingGuard.spec.ts
  50. 1 1
      test/functional-tests/node-transformers/preparing-transformers/obfuscating-guards/conditional-comment-obfuscating-guard/ConditionalCommentObfuscatingGuard.spec.ts
  51. 1 1
      test/functional-tests/options/OptionsNormalizer.spec.ts
  52. 1 1
      test/functional-tests/templates/GlobalVariableNoEvalTemplate.spec.ts
  53. 1 1
      test/functional-tests/templates/debug-protection-nodes/DebugProtectionFunctionCallTemplate.spec.ts
  54. 1 1
      test/functional-tests/templates/domain-lock-nodes/DomainLockNodeTemplate.spec.ts
  55. 1 1
      test/functional-tests/templates/string-array-nodes/StringArrayCallsWrapperNodeTemplate.spec.ts
  56. 1 0
      test/index.spec.ts
  57. 1 1
      test/unit-tests/analyzers/stack-trace-analyzer/StackTraceAnalyzer.spec.ts
  58. 27 29
      test/unit-tests/cli/sanitizers/ArraySanitizer.spec.ts
  59. 39 41
      test/unit-tests/cli/sanitizers/BooleanSanitizer.spec.ts
  60. 18 20
      test/unit-tests/cli/sanitizers/IdentifierNamesGeneratorSanitizer.spec.ts
  61. 18 20
      test/unit-tests/cli/sanitizers/ObfuscationTargetSanitizer.spec.ts
  62. 18 20
      test/unit-tests/cli/sanitizers/SourceMapModeSanitizer.spec.ts
  63. 49 51
      test/unit-tests/cli/sanitizers/StringArrayEncodingSanitizer.spec.ts
  64. 3 3
      test/unit-tests/cli/utils/CLIUtils.spec.ts
  65. 1 1
      test/unit-tests/cli/utils/SourceCodeReader.spec.ts
  66. 121 123
      test/unit-tests/decorators/initializable/Initializable.spec.ts
  67. 1 1
      test/unit-tests/generators/identifier-names-generators/HexadecimalIdentifierNamesGenerator.spec.ts
  68. 1 1
      test/unit-tests/generators/identifier-names-generators/MangledlIdentifierNamesGenerator.spec.ts
  69. 1 1
      test/unit-tests/javascript-obfuscator/EspreeFacade.spec.ts
  70. 1 1
      test/unit-tests/javascript-obfuscator/JavaScriptObfuscator.spec.ts
  71. 4 4
      test/unit-tests/logger/Logger.spec.ts
  72. 1 1
      test/unit-tests/node-transformers/preparing-transformers/ObfuscatingGuardsTransformer.spec.ts
  73. 22 22
      test/unit-tests/node/node-appender/NodeAppender.spec.ts
  74. 16 16
      test/unit-tests/node/node-guards/NodeGuards.spec.ts
  75. 3 3
      test/unit-tests/node/node-metadata/NodeMetadata.spec.ts
  76. 28 28
      test/unit-tests/node/node-utils/NodeUtils.spec.ts
  77. 1 1
      test/unit-tests/obfuscation-result/ObfuscationResult.spec.ts
  78. 1 1
      test/unit-tests/options/ValidationErrorsFormatter.spec.ts
  79. 1 1
      test/unit-tests/source-map/SourceMapCorrector.spec.ts
  80. 7 7
      test/unit-tests/storages/ArrayStorage.spec.ts
  81. 8 8
      test/unit-tests/storages/MapStorage.spec.ts
  82. 9 9
      test/unit-tests/utils/ArrayUtils.spec.ts
  83. 3 3
      test/unit-tests/utils/CryptUtils.spec.ts
  84. 1 1
      test/unit-tests/utils/EscapeSequenceEncoder.spec.ts
  85. 99 0
      test/unit-tests/utils/NumberUtils.spec.ts
  86. 6 165
      test/unit-tests/utils/Utils.spec.ts

Dosya farkı çok büyük olduğundan ihmal edildi
+ 0 - 0
dist/index.browser.js


Dosya farkı çok büyük olduğundan ihmal edildi
+ 0 - 0
dist/index.cli.js


Dosya farkı çok büyük olduğundan ihmal edildi
+ 0 - 0
dist/index.js


+ 2 - 2
src/custom-nodes/console-output-nodes/group/ConsoleOutputCustomNodeGroup.ts

@@ -63,7 +63,7 @@ export class ConsoleOutputCustomNodeGroup extends AbstractCustomNodeGroup {
 
         // consoleOutputDisableExpressionNode append
         this.appendCustomNodeIfExist(CustomNode.ConsoleOutputDisableExpressionNode, (customNode: ICustomNode) => {
-            NodeAppender.appendNodeToOptimalBlockScope(
+            NodeAppender.appendToOptimalBlockScope(
                 stackTraceData,
                 blockScopeNode,
                 customNode.getNode(),
@@ -81,7 +81,7 @@ export class ConsoleOutputCustomNodeGroup extends AbstractCustomNodeGroup {
                 targetBlockScope = blockScopeNode;
             }
 
-            NodeAppender.prependNode(targetBlockScope, customNode.getNode());
+            NodeAppender.prepend(targetBlockScope, customNode.getNode());
         });
     }
 

+ 1 - 1
src/custom-nodes/control-flow-flattening-nodes/BinaryExpressionFunctionNode.ts

@@ -66,7 +66,7 @@ export class BinaryExpressionFunctionNode extends AbstractCustomNode {
             )
         );
 
-        NodeUtils.parentize(structure);
+        NodeUtils.parentizeAst(structure);
 
         return [structure];
     }

+ 1 - 1
src/custom-nodes/control-flow-flattening-nodes/BlockStatementControlFlowFlatteningNode.ts

@@ -127,7 +127,7 @@ export class BlockStatementControlFlowFlatteningNode extends AbstractCustomNode
             )
         ]);
 
-        NodeUtils.parentize(structure);
+        NodeUtils.parentizeAst(structure);
 
         return [structure];
     }

+ 1 - 1
src/custom-nodes/control-flow-flattening-nodes/CallExpressionFunctionNode.ts

@@ -73,7 +73,7 @@ export class CallExpressionFunctionNode extends AbstractCustomNode {
             )
         );
 
-        NodeUtils.parentize(structure);
+        NodeUtils.parentizeAst(structure);
 
         return [structure];
     }

+ 1 - 1
src/custom-nodes/control-flow-flattening-nodes/LogicalExpressionFunctionNode.ts

@@ -66,7 +66,7 @@ export class LogicalExpressionFunctionNode extends AbstractCustomNode {
             )
         );
 
-        NodeUtils.parentize(structure);
+        NodeUtils.parentizeAst(structure);
 
         return [structure];
     }

+ 1 - 1
src/custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/CallExpressionControlFlowStorageCallNode.ts

@@ -91,7 +91,7 @@ export class CallExpressionControlFlowStorageCallNode extends AbstractCustomNode
             )
         );
 
-        NodeUtils.parentize(structure);
+        NodeUtils.parentizeAst(structure);
 
         return [structure];
     }

+ 1 - 1
src/custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/ControlFlowStorageNode.ts

@@ -73,7 +73,7 @@ export class ControlFlowStorageNode extends AbstractCustomNode {
             )
         ]);
 
-        structure = NodeUtils.parentize(structure);
+        structure = NodeUtils.parentizeAst(structure);
 
         return [structure];
     }

+ 1 - 1
src/custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/ExpressionWithOperatorControlFlowStorageCallNode.ts

@@ -87,7 +87,7 @@ export class ExpressionWithOperatorControlFlowStorageCallNode extends AbstractCu
             )
         );
 
-        NodeUtils.parentize(structure);
+        NodeUtils.parentizeAst(structure);
 
         return [structure];
     }

+ 1 - 1
src/custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/StringLiteralControlFlowStorageCallNode.ts

@@ -61,7 +61,7 @@ export class StringLiteralControlFlowStorageCallNode extends AbstractCustomNode
             )
         );
 
-        NodeUtils.parentize(structure);
+        NodeUtils.parentizeAst(structure);
 
         return [structure];
     }

+ 1 - 1
src/custom-nodes/dead-code-injection-nodes/BlockStatementDeadCodeInjectionNode.ts

@@ -82,7 +82,7 @@ export class BlockStatementDeadCodeInjectionNode extends AbstractCustomNode {
             )
         ]);
 
-        NodeUtils.parentize(structure);
+        NodeUtils.parentizeAst(structure);
 
         return [structure];
     }

+ 4 - 4
src/custom-nodes/debug-protection-nodes/group/DebugProtectionCustomNodeGroup.ts

@@ -63,7 +63,7 @@ export class DebugProtectionCustomNodeGroup extends AbstractCustomNodeGroup {
 
         // debugProtectionFunctionCallNode append
         this.appendCustomNodeIfExist(CustomNode.DebugProtectionFunctionCallNode, (customNode: ICustomNode) => {
-            NodeAppender.appendNodeToOptimalBlockScope(
+            NodeAppender.appendToOptimalBlockScope(
                 stackTraceData,
                 blockScopeNode,
                 customNode.getNode(),
@@ -73,7 +73,7 @@ export class DebugProtectionCustomNodeGroup extends AbstractCustomNodeGroup {
 
         // debugProtectionFunctionNode append
         this.appendCustomNodeIfExist(CustomNode.DebugProtectionFunctionNode, (customNode: ICustomNode) => {
-            NodeAppender.appendNode(blockScopeNode, customNode.getNode());
+            NodeAppender.append(blockScopeNode, customNode.getNode());
         });
 
         // debugProtectionFunctionIntervalNode append
@@ -81,7 +81,7 @@ export class DebugProtectionCustomNodeGroup extends AbstractCustomNodeGroup {
             const programBodyLength: number = blockScopeNode.body.length;
             const randomIndex: number = this.randomGenerator.getRandomInteger(0, programBodyLength);
 
-            NodeAppender.insertNodeAtIndex(blockScopeNode, customNode.getNode(), randomIndex);
+            NodeAppender.insertAtIndex(blockScopeNode, customNode.getNode(), randomIndex);
         });
 
         // nodeCallsControllerFunctionNode append
@@ -94,7 +94,7 @@ export class DebugProtectionCustomNodeGroup extends AbstractCustomNodeGroup {
                 targetBlockScope = blockScopeNode;
             }
 
-            NodeAppender.prependNode(targetBlockScope, customNode.getNode());
+            NodeAppender.prepend(targetBlockScope, customNode.getNode());
         });
     }
 

+ 2 - 2
src/custom-nodes/domain-lock-nodes/group/DomainLockCustomNodeGroup.ts

@@ -63,7 +63,7 @@ export class DomainLockCustomNodeGroup extends AbstractCustomNodeGroup {
 
         // domainLockNode append
         this.appendCustomNodeIfExist(CustomNode.DomainLockNode, (customNode: ICustomNode) => {
-            NodeAppender.appendNodeToOptimalBlockScope(
+            NodeAppender.appendToOptimalBlockScope(
                 stackTraceData,
                 blockScopeNode,
                 customNode.getNode(),
@@ -81,7 +81,7 @@ export class DomainLockCustomNodeGroup extends AbstractCustomNodeGroup {
                 targetBlockScope = blockScopeNode;
             }
 
-            NodeAppender.prependNode(targetBlockScope, customNode.getNode());
+            NodeAppender.prepend(targetBlockScope, customNode.getNode());
         });
     }
 

+ 2 - 2
src/custom-nodes/self-defending-nodes/group/SelfDefendingCustomNodeGroup.ts

@@ -63,7 +63,7 @@ export class SelfDefendingCustomNodeGroup extends AbstractCustomNodeGroup {
 
         // selfDefendingUnicodeNode append
         this.appendCustomNodeIfExist(CustomNode.SelfDefendingUnicodeNode, (customNode: ICustomNode) => {
-            NodeAppender.appendNodeToOptimalBlockScope(
+            NodeAppender.appendToOptimalBlockScope(
                 stackTraceData,
                 blockScopeNode,
                 customNode.getNode(),
@@ -81,7 +81,7 @@ export class SelfDefendingCustomNodeGroup extends AbstractCustomNodeGroup {
                 targetBlockScope = blockScopeNode;
             }
 
-            NodeAppender.prependNode(targetBlockScope, customNode.getNode());
+            NodeAppender.prepend(targetBlockScope, customNode.getNode());
         });
     }
 

+ 2 - 2
src/custom-nodes/string-array-nodes/StringArrayRotateFunctionNode.ts

@@ -20,7 +20,7 @@ import { StringArrayRotateFunctionTemplate } from '../../templates/string-array-
 import { AbstractCustomNode } from '../AbstractCustomNode';
 import { JavaScriptObfuscator } from '../../JavaScriptObfuscatorFacade';
 import { NodeUtils } from '../../node/NodeUtils';
-import { Utils } from '../../utils/Utils';
+import { NumberUtils } from '../../utils/NumberUtils';
 
 @injectable()
 export class StringArrayRotateFunctionNode extends AbstractCustomNode {
@@ -101,7 +101,7 @@ export class StringArrayRotateFunctionNode extends AbstractCustomNode {
                 code,
                 timesName,
                 stringArrayName: this.stringArrayName,
-                stringArrayRotateValue: Utils.decToHex(this.stringArrayRotateValue),
+                stringArrayRotateValue: NumberUtils.toHex(this.stringArrayRotateValue),
                 whileFunctionName
             }),
             {

+ 3 - 3
src/custom-nodes/string-array-nodes/group/StringArrayCustomNodeGroup.ts

@@ -74,17 +74,17 @@ export class StringArrayCustomNodeGroup extends AbstractCustomNodeGroup {
 
         // stringArrayNode append
         this.appendCustomNodeIfExist(CustomNode.StringArrayNode, (customNode: ICustomNode) => {
-            NodeAppender.prependNode(blockScopeNode, customNode.getNode());
+            NodeAppender.prepend(blockScopeNode, customNode.getNode());
         });
 
         // stringArrayCallsWrapper append
         this.appendCustomNodeIfExist(CustomNode.StringArrayCallsWrapper, (customNode: ICustomNode) => {
-            NodeAppender.insertNodeAtIndex(blockScopeNode, customNode.getNode(), 1);
+            NodeAppender.insertAtIndex(blockScopeNode, customNode.getNode(), 1);
         });
 
         // stringArrayRotateFunctionNode append
         this.appendCustomNodeIfExist(CustomNode.StringArrayRotateFunctionNode, (customNode: ICustomNode) => {
-            NodeAppender.insertNodeAtIndex(blockScopeNode, customNode.getNode(), 1);
+            NodeAppender.insertAtIndex(blockScopeNode, customNode.getNode(), 1);
         });
     }
 

+ 3 - 3
src/generators/identifier-names-generators/AbstractIdentifierNamesGenerator.ts

@@ -40,13 +40,13 @@ export abstract class AbstractIdentifierNamesGenerator implements IIdentifierNam
     public abstract generateWithPrefix (): string;
 
     /**
-     * @param {string} identifierName
+     * @param {string} name
      * @returns {boolean}
      */
-    public isValidIdentifierName (identifierName: string): boolean {
+    public isValidIdentifierName (name: string): boolean {
         return this.options.reservedNames.length
             ? !this.options.reservedNames.some((reservedName: string) =>
-                new RegExp(reservedName, 'g').exec(identifierName) !== null
+                new RegExp(reservedName, 'g').exec(name) !== null
             )
             : true;
 

+ 2 - 1
src/generators/identifier-names-generators/HexadecimalIdentifierNamesGenerator.ts

@@ -5,6 +5,7 @@ import { IOptions } from '../../interfaces/options/IOptions';
 import { IRandomGenerator } from '../../interfaces/utils/IRandomGenerator';
 
 import { AbstractIdentifierNamesGenerator } from './AbstractIdentifierNamesGenerator';
+import { NumberUtils } from '../../utils/NumberUtils';
 import { Utils } from '../../utils/Utils';
 
 @injectable()
@@ -37,7 +38,7 @@ export class HexadecimalIdentifierNamesGenerator extends AbstractIdentifierNames
         const rangeMinInteger: number = 10000;
         const rangeMaxInteger: number = 99_999_999;
         const randomInteger: number = this.randomGenerator.getRandomInteger(rangeMinInteger, rangeMaxInteger);
-        const hexadecimalNumber: string = Utils.decToHex(randomInteger);
+        const hexadecimalNumber: string = NumberUtils.toHex(randomInteger);
         const baseIdentifierName: string = hexadecimalNumber.substr(0, HexadecimalIdentifierNamesGenerator.baseIdentifierNameLength);
         const identifierName: string = `_${Utils.hexadecimalPrefix}${baseIdentifierName}`;
 

+ 3 - 3
src/interfaces/utils/IArrayUtils.d.ts

@@ -3,18 +3,18 @@ export interface IArrayUtils {
      * @param length
      * @return {number[]}
      */
-    arrayRange (length: number): number[];
+    createWithRange (length: number): number[];
 
     /**
      * @param array
      * @param times
      * @returns {T[]}
      */
-    arrayRotate <T> (array: T[], times: number): T[];
+    rotate <T> (array: T[], times: number): T[];
 
     /**
      * @param array
      * @return {T[]}
      */
-    arrayShuffle <T> (array: T[]): T[];
+    shuffle <T> (array: T[]): T[];
 }

+ 2 - 2
src/node-transformers/control-flow-transformers/BlockStatementControlFlowTransformer.ts

@@ -133,8 +133,8 @@ export class BlockStatementControlFlowTransformer extends AbstractNodeTransforme
         }
 
         const blockStatementBody: ESTree.Statement[] = blockStatementNode.body;
-        const originalKeys: number[] = this.arrayUtils.arrayRange(blockStatementBody.length);
-        const shuffledKeys: number[] = this.arrayUtils.arrayShuffle(originalKeys);
+        const originalKeys: number[] = this.arrayUtils.createWithRange(blockStatementBody.length);
+        const shuffledKeys: number[] = this.arrayUtils.shuffle(originalKeys);
         const originalKeysIndexesInShuffledArray: number[] = originalKeys.map((key: number) => shuffledKeys.indexOf(key));
         const blockStatementControlFlowFlatteningCustomNode: ICustomNode = this.controlFlowCustomNodeFactory(
             ControlFlowCustomNode.BlockStatementControlFlowFlatteningNode

+ 1 - 1
src/node-transformers/control-flow-transformers/FunctionControlFlowTransformer.ts

@@ -155,7 +155,7 @@ export class FunctionControlFlowTransformer extends AbstractNodeTransformer {
         );
 
         controlFlowStorageCustomNode.initialize(controlFlowStorage);
-        NodeAppender.prependNode(hostNode, controlFlowStorageCustomNode.getNode());
+        NodeAppender.prepend(hostNode, controlFlowStorageCustomNode.getNode());
         this.hostNodesWithControlFlowNode.add(hostNode);
 
         return functionNode;

+ 99 - 133
src/node-transformers/converting-transformers/ObjectExpressionKeysTransformer.ts

@@ -20,9 +20,9 @@ import { NodeUtils } from '../../node/NodeUtils';
 @injectable()
 export class ObjectExpressionKeysTransformer extends AbstractNodeTransformer {
     /**
-     * @type {Map<Node, TNodeWithScope>}
+     * @type {Map<ESTree.ObjectExpression, TNodeWithScope>}
      */
-    private readonly cachedScopeNodesMap: Map <ESTree.Node, TNodeWithScope> = new Map();
+    private readonly cachedObjectExpressionScopesMap: Map <ESTree.ObjectExpression, TNodeWithScope> = new Map();
 
     /**
      * @param {IRandomGenerator} randomGenerator
@@ -35,30 +35,6 @@ export class ObjectExpressionKeysTransformer extends AbstractNodeTransformer {
         super(randomGenerator, options);
     }
 
-    /**
-     * @param {TNodeWithScope} scopeNode
-     * @param {Node} hostNode
-     * @param {ExpressionStatement[]} expressionStatements
-     */
-    private static appendExpressionStatements (
-        scopeNode: TNodeWithScope,
-        hostNode: ESTree.Node,
-        expressionStatements: ESTree.ExpressionStatement[]
-    ): void {
-        const hostNodeScope: ESTree.Node = ObjectExpressionKeysTransformer.getHostStatement(hostNode);
-
-        NodeAppender.insertNodeAfter(scopeNode, expressionStatements, hostNodeScope);
-    }
-
-    /**
-     * @param {Property[]} properties
-     * @param {number[]} removablePropertyIds
-     * @returns {Property[]}
-     */
-    private static filterObjectExpressionProperties (properties: ESTree.Property[], removablePropertyIds: number[]): ESTree.Property[] {
-        return properties.filter((property: ESTree.Property, index: number) => !removablePropertyIds.includes(index));
-    }
-
     /**
      * Returns host statement of object expression node
      *
@@ -92,7 +68,9 @@ export class ObjectExpressionKeysTransformer extends AbstractNodeTransformer {
 
         if (NodeGuards.isLiteralNode(propertyKeyNode) && typeof propertyKeyNode.value === 'string') {
             return propertyKeyNode.value;
-        } else if (NodeGuards.isIdentifierNode(propertyKeyNode)) {
+        }
+
+        if (NodeGuards.isIdentifierNode(propertyKeyNode)) {
             return propertyKeyNode.name;
         }
 
@@ -100,14 +78,14 @@ export class ObjectExpressionKeysTransformer extends AbstractNodeTransformer {
     }
 
     /**
-     * @param {Expression | Pattern} propertyValueNode
-     * @returns {propertyValueNode is Expression}
+     * @param {Node} node
+     * @returns {propertyValueNode is Pattern}
      */
-    private static isValidExpressionNode (propertyValueNode: ESTree.Expression | ESTree.Pattern): propertyValueNode is ESTree.Expression {
-        return !NodeGuards.isObjectPatternNode(propertyValueNode)
-            && !NodeGuards.isArrayPatternNode(propertyValueNode)
-            && !NodeGuards.isAssignmentPatternNode(propertyValueNode)
-            && !NodeGuards.isRestElementNode(propertyValueNode);
+    private static isProhibitedPattern (node: ESTree.Node): node is ESTree.Pattern {
+        return NodeGuards.isObjectPatternNode(node)
+            || NodeGuards.isArrayPatternNode(node)
+            || NodeGuards.isAssignmentPatternNode(node)
+            || NodeGuards.isRestElementNode(node);
     }
 
     /**
@@ -115,23 +93,21 @@ export class ObjectExpressionKeysTransformer extends AbstractNodeTransformer {
      * @returns {IVisitor | null}
      */
     public getVisitor (transformationStage: TransformationStage): IVisitor | null {
-        switch (transformationStage) {
-            case TransformationStage.Converting:
-                return {
-                    enter: (node: ESTree.Node, parentNode: ESTree.Node | null) => {
-                        if (
-                            this.options.transformObjectKeys
-                            && parentNode
-                            && NodeGuards.isObjectExpressionNode(node)
-                        ) {
-                            return this.transformNode(node, parentNode);
-                        }
-                    }
-                };
-
-            default:
-                return null;
+        if (transformationStage !== TransformationStage.Converting) {
+            return null;
         }
+
+        return {
+            enter: (node: ESTree.Node, parentNode: ESTree.Node | null) => {
+                if (
+                    this.options.transformObjectKeys
+                    && parentNode
+                    && NodeGuards.isObjectExpressionNode(node)
+                ) {
+                    return this.transformNode(node, parentNode);
+                }
+            }
+        };
     }
 
     /**
@@ -151,86 +127,29 @@ export class ObjectExpressionKeysTransformer extends AbstractNodeTransformer {
      * @returns {NodeGuards}
      */
     public transformNode (objectExpressionNode: ESTree.ObjectExpression, parentNode: ESTree.Node): ESTree.Node {
-        if (NodeGuards.isVariableDeclaratorNode(parentNode)) {
-            return this.transformVariableDeclaratorHostObjectExpression(objectExpressionNode, parentNode);
-        }
-
-        if (NodeGuards.isAssignmentExpressionNode(parentNode)) {
-            return this.transformAssignmentExpressionHostObjectExpression(objectExpressionNode, parentNode);
-        }
-
-        return objectExpressionNode;
-    }
-
-    /**
-     * @param {ObjectExpression} objectExpressionNode
-     * @param {VariableDeclarator} variableDeclaratorNode
-     * @returns {Node}
-     */
-    private transformVariableDeclaratorHostObjectExpression(
-        objectExpressionNode: ESTree.ObjectExpression,
-        variableDeclaratorNode: ESTree.VariableDeclarator
-    ): ESTree.Node {
-        // should pass only Expression nodes as MemberExpression.object value
-        if (!NodeGuards.isIdentifierNode(variableDeclaratorNode.id)) {
+        if (!objectExpressionNode.properties.length) {
             return objectExpressionNode;
         }
 
-        const scopeNode: TNodeWithScope | null = NodeUtils.getScopeOfNode(variableDeclaratorNode);
-
-        if (!scopeNode || !NodeGuards.isNodeHasScope(scopeNode)) {
-            return objectExpressionNode;
-        }
-
-        this.cachedScopeNodesMap.set(variableDeclaratorNode, scopeNode);
-
-        return this.transformObjectExpressionNode(
-            objectExpressionNode,
-            variableDeclaratorNode.id,
-            variableDeclaratorNode
-        );
-    }
-
-    /**
-     * @param {ObjectExpression} objectExpressionNode
-     * @param {AssignmentExpression} assignmentExpressionNode
-     * @returns {Node}
-     */
-    private transformAssignmentExpressionHostObjectExpression(
-        objectExpressionNode: ESTree.ObjectExpression,
-        assignmentExpressionNode: ESTree.AssignmentExpression
-    ): ESTree.Node {
-        const leftNode: ESTree.MemberExpression | ESTree.Pattern = assignmentExpressionNode.left;
-
-        if (!ObjectExpressionKeysTransformer.isValidExpressionNode(leftNode)) {
-            return objectExpressionNode;
+        if (NodeGuards.isVariableDeclaratorNode(parentNode)) {
+            return this.transformWithVariableDeclaratorHost(objectExpressionNode, parentNode);
         }
 
-        const scopeNode: TNodeWithScope | null = NodeUtils.getScopeOfNode(assignmentExpressionNode);
-
-        if (!scopeNode || !NodeGuards.isNodeHasScope(scopeNode)) {
-            return objectExpressionNode;
+        if (NodeGuards.isAssignmentExpressionNode(parentNode)) {
+            return this.transformWithAssignmentExpressionHost(objectExpressionNode, parentNode);
         }
 
-        this.cachedScopeNodesMap.set(assignmentExpressionNode, scopeNode);
-
-        return this.transformObjectExpressionNode(
-            objectExpressionNode,
-            leftNode,
-            assignmentExpressionNode
-        );
+        return objectExpressionNode;
     }
 
     /**
      * @param {Property[]} properties
-     * @param {Expression} memberExpressionObject
-     * @param {Node} hostNode
+     * @param {Expression} memberExpressionHostNode
      * @returns {[ExpressionStatement[] , number[]]}
      */
     private extractPropertiesToExpressionStatements (
         properties: ESTree.Property[],
-        memberExpressionObject: ESTree.Expression,
-        hostNode: ESTree.Node
+        memberExpressionHostNode: ESTree.Expression
     ): [ESTree.ExpressionStatement[], number[]] {
         const propertiesLength: number = properties.length;
         const expressionStatements: ESTree.ExpressionStatement[] = [];
@@ -241,7 +160,7 @@ export class ObjectExpressionKeysTransformer extends AbstractNodeTransformer {
             const propertyValue: ESTree.Expression | ESTree.Pattern = property.value;
 
             // invalid property nodes
-            if (!ObjectExpressionKeysTransformer.isValidExpressionNode(propertyValue)) {
+            if (ObjectExpressionKeysTransformer.isProhibitedPattern(propertyValue)) {
                 continue;
             }
 
@@ -263,7 +182,7 @@ export class ObjectExpressionKeysTransformer extends AbstractNodeTransformer {
                 ? NodeFactory.literalNode(propertyKeyName)
                 : NodeFactory.identifierNode(propertyKeyName);
             const memberExpressionNode: ESTree.MemberExpression = NodeFactory
-                .memberExpressionNode(memberExpressionObject, memberExpressionProperty, true);
+                .memberExpressionNode(memberExpressionHostNode, memberExpressionProperty, true);
             const expressionStatementNode: ESTree.ExpressionStatement = NodeFactory.expressionStatementNode(
                 NodeFactory.assignmentExpressionNode('=', memberExpressionNode, propertyValue)
             );
@@ -272,7 +191,7 @@ export class ObjectExpressionKeysTransformer extends AbstractNodeTransformer {
              * Stage 3: recursively processing nested object expressions
              */
             if (NodeGuards.isObjectExpressionNode(property.value)) {
-                this.transformObjectExpressionNode(property.value, memberExpressionNode, hostNode);
+                this.transformObjectExpressionNode(property.value, memberExpressionNode);
             }
 
             /**
@@ -287,34 +206,81 @@ export class ObjectExpressionKeysTransformer extends AbstractNodeTransformer {
 
     /**
      * @param {ObjectExpression} objectExpressionNode
-     * @param {Expression} memberExpressionObjectNode
-     * @param {Node} hostNode
+     * @returns {TNodeWithScope}
+     */
+    private getScopeNode (objectExpressionNode: ESTree.ObjectExpression): TNodeWithScope {
+        if (this.cachedObjectExpressionScopesMap.has(objectExpressionNode)) {
+            return <TNodeWithScope>this.cachedObjectExpressionScopesMap.get(objectExpressionNode);
+        }
+
+        const scopeNode: TNodeWithScope = NodeUtils.getScopeOfNode(objectExpressionNode);
+
+        this.cachedObjectExpressionScopesMap.set(objectExpressionNode, scopeNode);
+
+        return scopeNode;
+    }
+
+    /**
+     * @param {ObjectExpression} objectExpressionNode
+     * @param {VariableDeclarator} hostNode
      * @returns {Node}
      */
-    private transformObjectExpressionNode (
+    private transformWithVariableDeclaratorHost (
         objectExpressionNode: ESTree.ObjectExpression,
-        memberExpressionObjectNode: ESTree.Expression,
-        hostNode: ESTree.Node
+        hostNode: ESTree.VariableDeclarator
     ): ESTree.Node {
-        const properties: ESTree.Property[] = objectExpressionNode.properties;
-
-        if (!properties.length) {
+        // should pass only Expression nodes as MemberExpression.object value
+        if (!NodeGuards.isIdentifierNode(hostNode.id)) {
             return objectExpressionNode;
         }
 
-        const scopeNode: TNodeWithScope | undefined = this.cachedScopeNodesMap.get(hostNode);
+        return this.transformObjectExpressionNode(
+            objectExpressionNode,
+            hostNode.id
+        );
+    }
+
+    /**
+     * @param {ObjectExpression} objectExpressionNode
+     * @param {AssignmentExpression} hostNode
+     * @returns {Node}
+     */
+    private transformWithAssignmentExpressionHost (
+        objectExpressionNode: ESTree.ObjectExpression,
+        hostNode: ESTree.AssignmentExpression
+    ): ESTree.Node {
+        const leftNode: ESTree.MemberExpression | ESTree.Pattern = hostNode.left;
 
-        if (!scopeNode) {
+        // left node shouldn't be as Pattern node
+        if (ObjectExpressionKeysTransformer.isProhibitedPattern(leftNode)) {
             return objectExpressionNode;
         }
 
+        return this.transformObjectExpressionNode(
+            objectExpressionNode,
+            leftNode
+        );
+    }
+
+    /**
+     * @param {ObjectExpression} objectExpressionNode
+     * @param {Expression} memberExpressionHostNode
+     * @returns {Node}
+     */
+    private transformObjectExpressionNode (
+        objectExpressionNode: ESTree.ObjectExpression,
+        memberExpressionHostNode: ESTree.Expression
+    ): ESTree.Node {
+        const properties: ESTree.Property[] = objectExpressionNode.properties;
         const [expressionStatements, removablePropertyIds]: [ESTree.ExpressionStatement[], number[]] = this
-            .extractPropertiesToExpressionStatements(properties, memberExpressionObjectNode, hostNode);
+            .extractPropertiesToExpressionStatements(properties, memberExpressionHostNode);
+        const hostStatement: ESTree.Statement = ObjectExpressionKeysTransformer.getHostStatement(objectExpressionNode);
+        const scopeNode: TNodeWithScope = this.getScopeNode(objectExpressionNode);
 
-        objectExpressionNode.properties = ObjectExpressionKeysTransformer
-            .filterObjectExpressionProperties(properties, removablePropertyIds);
-        ObjectExpressionKeysTransformer
-            .appendExpressionStatements(scopeNode, objectExpressionNode, expressionStatements);
+        objectExpressionNode.properties = properties.filter((property: ESTree.Property, index: number) =>
+            !removablePropertyIds.includes(index)
+        );
+        NodeAppender.insertAfter(scopeNode, expressionStatements, hostStatement);
 
         return objectExpressionNode;
     }

+ 3 - 2
src/node-transformers/obfuscating-transformers/obfuscating-replacers/literal-obfuscating-replacers/NumberLiteralObfuscatingReplacer.ts

@@ -7,6 +7,7 @@ import { IOptions } from '../../../../interfaces/options/IOptions';
 
 import { AbstractObfuscatingReplacer } from '../AbstractObfuscatingReplacer';
 import { NodeFactory } from '../../../../node/NodeFactory';
+import { NumberUtils } from '../../../../utils/NumberUtils';
 import { Utils } from '../../../../utils/Utils';
 
 @injectable()
@@ -35,10 +36,10 @@ export class NumberLiteralObfuscatingReplacer extends AbstractObfuscatingReplace
         if (this.numberLiteralCache.has(nodeValue)) {
             rawValue = <string>this.numberLiteralCache.get(nodeValue);
         } else {
-            if (!Utils.isCeilNumber(nodeValue)) {
+            if (!NumberUtils.isCeil(nodeValue)) {
                 rawValue = String(nodeValue);
             } else {
-                rawValue = `${Utils.hexadecimalPrefix}${Utils.decToHex(nodeValue)}`;
+                rawValue = `${Utils.hexadecimalPrefix}${NumberUtils.toHex(nodeValue)}`;
             }
 
             this.numberLiteralCache.set(nodeValue, rawValue);

+ 2 - 1
src/node-transformers/obfuscating-transformers/obfuscating-replacers/literal-obfuscating-replacers/StringLiteralObfuscatingReplacer.ts

@@ -17,6 +17,7 @@ import { StringArrayEncoding } from '../../../../enums/StringArrayEncoding';
 import { AbstractObfuscatingReplacer } from '../AbstractObfuscatingReplacer';
 import { NodeMetadata } from '../../../../node/NodeMetadata';
 import { NodeFactory } from '../../../../node/NodeFactory';
+import { NumberUtils } from '../../../../utils/NumberUtils';
 import { Utils } from '../../../../utils/Utils';
 
 @injectable()
@@ -174,7 +175,7 @@ export class StringLiteralObfuscatingReplacer extends AbstractObfuscatingReplace
             };
         }
 
-        const hexadecimalRawIndex: string = Utils.decToHex(stringArrayStorageLength);
+        const hexadecimalRawIndex: string = NumberUtils.toHex(stringArrayStorageLength);
         const hexadecimalIndex: string = `${Utils.hexadecimalPrefix}${hexadecimalRawIndex}`;
 
         this.stringLiteralHexadecimalIndexCache.set(value, hexadecimalIndex);

+ 65 - 64
src/node/NodeAppender.ts

@@ -9,15 +9,15 @@ import { NodeGuards } from './NodeGuards';
 
 export class NodeAppender {
     /**
-     * @param {TNodeWithScope} scopeNode
-     * @param {TStatement[]} scopeStatements
+     * @param {TNodeWithScope} scope
+     * @param {TStatement[]} statements
      */
-    public static appendNode (scopeNode: TNodeWithScope, scopeStatements: TStatement[]): void {
-        scopeStatements = NodeAppender.parentizeScopeStatementsBeforeAppend(scopeNode, scopeStatements);
+    public static append (scope: TNodeWithScope, statements: TStatement[]): void {
+        statements = NodeAppender.parentizeScopeStatementsBeforeAppend(scope, statements);
 
-        NodeAppender.setScopeNodeStatements(scopeNode, [
-            ...NodeAppender.getScopeNodeStatements(scopeNode),
-            ...scopeStatements
+        NodeAppender.setScopeStatements(scope, [
+            ...NodeAppender.getScopeStatements(scope),
+            ...statements
         ]);
     }
 
@@ -38,45 +38,38 @@ export class NodeAppender {
      *
      * Appends node into block statement of `baz` function expression
      *
-     * @param {IStackTraceData[]} blockScopeStackTraceData
+     * @param {IStackTraceData[]} stackTraceData
      * @param {TNodeWithBlockScope} blockScopeNode
-     * @param {TStatement[]} nodeBodyStatements
+     * @param {TStatement[]} bodyStatements
      * @param {number} index
      */
-    public static appendNodeToOptimalBlockScope (
-        blockScopeStackTraceData: IStackTraceData[],
+    public static appendToOptimalBlockScope (
+        stackTraceData: IStackTraceData[],
         blockScopeNode: TNodeWithBlockScope,
-        nodeBodyStatements: TStatement[],
+        bodyStatements: TStatement[],
         index: number = 0
     ): void {
-        let targetBlockScope: TNodeWithBlockScope;
+        const targetBlockScope: TNodeWithBlockScope = stackTraceData.length
+            ? NodeAppender.getOptimalBlockScope(stackTraceData, index)
+            : blockScopeNode;
 
-        if (!blockScopeStackTraceData.length) {
-            targetBlockScope = blockScopeNode;
-        } else {
-            targetBlockScope = NodeAppender.getOptimalBlockScope(
-                blockScopeStackTraceData,
-                index
-            );
-        }
-
-        NodeAppender.prependNode(targetBlockScope, nodeBodyStatements);
+        NodeAppender.prepend(targetBlockScope, bodyStatements);
     }
 
     /**
      * Returns deepest block scope node at given deep.
      *
-     * @param {IStackTraceData[]} blockScopeTraceData
+     * @param {IStackTraceData[]} stackTraceData
      * @param {number} index
      * @param {number} deep
      * @returns {BlockStatement}
      */
     public static getOptimalBlockScope (
-        blockScopeTraceData: IStackTraceData[],
+        stackTraceData: IStackTraceData[],
         index: number,
         deep: number = Infinity
     ): ESTree.BlockStatement {
-        const firstCall: IStackTraceData = blockScopeTraceData[index];
+        const firstCall: IStackTraceData = stackTraceData[index];
 
         if (deep <= 0) {
             throw new Error('Invalid `deep` argument value. Value should be bigger then 0.');
@@ -90,82 +83,90 @@ export class NodeAppender {
     }
 
     /**
-     * @param {TNodeWithScope} scopeNode
-     * @param {TStatement[]} scopeStatements
-     * @param {Node} targetStatement
+     * @param {TNodeWithScope} scope
+     * @param {TStatement[]} statements
+     * @param {Node} target
      */
-    public static insertNodeAfter (scopeNode: TNodeWithScope, scopeStatements: TStatement[], targetStatement: ESTree.Statement): void {
+    public static insertAfter (
+        scope: TNodeWithScope,
+        statements: TStatement[],
+        target: ESTree.Statement
+    ): void {
         const indexInScopeStatement: number = NodeAppender
-            .getScopeNodeStatements(scopeNode)
-            .indexOf(targetStatement);
+            .getScopeStatements(scope)
+            .indexOf(target);
 
-        NodeAppender.insertNodeAtIndex(scopeNode, scopeStatements, indexInScopeStatement + 1);
+        NodeAppender.insertAtIndex(scope, statements, indexInScopeStatement + 1);
     }
 
     /**
-     * @param {TNodeWithScope} scopeNode
-     * @param {TStatement[]} scopeStatements
+     * @param {TNodeWithScope} scope
+     * @param {TStatement[]} statements
      * @param {number} index
      */
-    public static insertNodeAtIndex (scopeNode: TNodeWithScope, scopeStatements: TStatement[], index: number): void {
-        scopeStatements = NodeAppender.parentizeScopeStatementsBeforeAppend(scopeNode, scopeStatements);
+    public static insertAtIndex (
+        scope: TNodeWithScope,
+        statements: TStatement[],
+        index: number
+    ): void {
+        statements = NodeAppender.parentizeScopeStatementsBeforeAppend(scope, statements);
 
-        NodeAppender.setScopeNodeStatements(scopeNode, [
-            ...NodeAppender.getScopeNodeStatements(scopeNode).slice(0, index),
-            ...scopeStatements,
-            ...NodeAppender.getScopeNodeStatements(scopeNode).slice(index)
+        NodeAppender.setScopeStatements(scope, [
+            ...NodeAppender.getScopeStatements(scope).slice(0, index),
+            ...statements,
+            ...NodeAppender.getScopeStatements(scope).slice(index)
         ]);
     }
 
     /**
-     * @param {TNodeWithScope} scopeNode
-     * @param {TStatement[]} scopeStatements
+     * @param {TNodeWithScope} scope
+     * @param {TStatement[]} statements
      */
-    public static prependNode (scopeNode: TNodeWithScope, scopeStatements: TStatement[]): void {
-        scopeStatements = NodeAppender.parentizeScopeStatementsBeforeAppend(scopeNode, scopeStatements);
+    public static prepend (scope: TNodeWithScope, statements: TStatement[]): void {
+        statements = NodeAppender.parentizeScopeStatementsBeforeAppend(scope, statements);
 
-        NodeAppender.setScopeNodeStatements(scopeNode, [
-            ...scopeStatements,
-            ...NodeAppender.getScopeNodeStatements(scopeNode),
+        NodeAppender.setScopeStatements(scope, [
+            ...statements,
+            ...NodeAppender.getScopeStatements(scope),
         ]);
     }
 
     /**
-     * @param {TNodeWithScope} scopeNode
+     * @param {TNodeWithScope} scope
      * @returns {TStatement[]}
      */
-    private static getScopeNodeStatements (scopeNode: TNodeWithScope): TStatement[] {
-        if (NodeGuards.isSwitchCaseNode(scopeNode)) {
-            return scopeNode.consequent;
+    private static getScopeStatements (scope: TNodeWithScope): TStatement[] {
+        if (NodeGuards.isSwitchCaseNode(scope)) {
+            return scope.consequent;
         }
 
-        return scopeNode.body;
+        return scope.body;
     }
 
     /**
-     * @param {TNodeWithScope} scopeNode
-     * @param {TStatement[]} scopeStatements
+     * @param {TNodeWithScope} scope
+     * @param {TStatement[]} statements
      * @returns {TStatement[]}
      */
-    private static parentizeScopeStatementsBeforeAppend (scopeNode: TNodeWithScope, scopeStatements: TStatement[]): TStatement[] {
-        scopeStatements.forEach((statement: TStatement) => {
-            statement.parentNode = scopeNode;
+    private static parentizeScopeStatementsBeforeAppend (scope: TNodeWithScope, statements: TStatement[]): TStatement[] {
+        statements.forEach((statement: TStatement) => {
+            statement.parentNode = scope;
         });
 
-        return scopeStatements;
+        return statements;
     }
 
     /**
-     * @param {TNodeWithScope} scopeNode
+     * @param {TNodeWithScope} scope
      * @param {TStatement[]} statements
      */
-    private static setScopeNodeStatements (scopeNode: TNodeWithScope, statements: TStatement[]): void {
-        if (NodeGuards.isSwitchCaseNode(scopeNode)) {
-            scopeNode.consequent = <ESTree.Statement[]>statements;
+    private static setScopeStatements (scope: TNodeWithScope, statements: TStatement[]): void {
+        if (NodeGuards.isSwitchCaseNode(scope)) {
+            scope.consequent = <ESTree.Statement[]>statements;
 
             return;
         }
 
-        scopeNode.body = statements;
+        scope.body = statements;
     }
 }

+ 27 - 25
src/node/NodeUtils.ts

@@ -13,18 +13,16 @@ import { NodeMetadata } from './NodeMetadata';
 
 export class NodeUtils {
     /**
-     * @param {T} node
+     * @param {T} literalNode
      * @returns {T}
      */
-    public static addXVerbatimPropertyToLiteralNode <T extends ESTree.Node = ESTree.Node> (node: T): T {
-        if (NodeGuards.isLiteralNode(node)) {
-            node['x-verbatim-property'] = {
-                content: node.raw,
-                precedence: escodegen.Precedence.Primary
-            };
-        }
+    public static addXVerbatimPropertyTo (literalNode: ESTree.Literal): ESTree.Literal {
+        literalNode['x-verbatim-property'] = {
+            content: literalNode.raw,
+            precedence: escodegen.Precedence.Primary
+        };
 
-        return node;
+        return literalNode;
     }
 
     /**
@@ -32,7 +30,7 @@ export class NodeUtils {
      * @returns {T}
      */
     public static clone <T extends ESTree.Node = ESTree.Node> (astTree: T): T {
-        return NodeUtils.parentize(NodeUtils.cloneRecursive(astTree));
+        return NodeUtils.parentizeAst(NodeUtils.cloneRecursive(astTree));
     }
 
     /**
@@ -45,7 +43,11 @@ export class NodeUtils {
         estraverse.replace(structure, {
             enter: (node: ESTree.Node, parentNode: ESTree.Node | null): ESTree.Node => {
                 NodeUtils.parentizeNode(node, parentNode);
-                NodeUtils.addXVerbatimPropertyToLiteralNode(node);
+
+                if (NodeGuards.isLiteralNode(node)) {
+                    NodeUtils.addXVerbatimPropertyTo(node);
+                }
+
                 NodeMetadata.set(node, { ignoredNode: false });
 
                 return node;
@@ -68,27 +70,27 @@ export class NodeUtils {
     }
 
     /**
-     * @param {Node} targetNode
+     * @param {Node} node
      * @returns {TNodeWithBlockScope[]}
      */
-    public static getBlockScopesOfNode (targetNode: ESTree.Node): TNodeWithBlockScope[] {
-        return NodeUtils.getBlockScopesOfNodeRecursive(targetNode);
+    public static getBlockScopesOfNode (node: ESTree.Node): TNodeWithBlockScope[] {
+        return NodeUtils.getBlockScopesOfNodeRecursive(node);
     }
 
     /**
-     * @param {Statement} node
+     * @param {Statement} statement
      * @returns {TStatement | null}
      */
-    public static getNextSiblingStatementNode (node: ESTree.Statement): TStatement | null {
-        return NodeUtils.getSiblingStatementNodeByOffset(node, 1);
+    public static getNextSiblingStatement (statement: ESTree.Statement): TStatement | null {
+        return NodeUtils.getSiblingStatementByOffset(statement, 1);
     }
 
     /**
-     * @param {Statement} node
+     * @param {Statement} statement
      * @returns {TStatement | null}
      */
-    public static getPreviousSiblingStatementNode (node: ESTree.Statement): TStatement | null {
-        return NodeUtils.getSiblingStatementNodeByOffset(node, -1);
+    public static getPreviousSiblingStatement (statement: ESTree.Statement): TStatement | null {
+        return NodeUtils.getSiblingStatementByOffset(statement, -1);
     }
 
     /**
@@ -125,7 +127,7 @@ export class NodeUtils {
      * @param {T} astTree
      * @returns {T}
      */
-    public static parentize <T extends ESTree.Node = ESTree.Node> (astTree: T): T {
+    public static parentizeAst <T extends ESTree.Node = ESTree.Node> (astTree: T): T {
         estraverse.replace(astTree, {
             enter: NodeUtils.parentizeNode
         });
@@ -231,16 +233,16 @@ export class NodeUtils {
     }
 
     /**
-     * @param {Statement} node
+     * @param {Statement} statement
      * @param {number} offset
      * @returns {TStatement | null}
      */
-    private static getSiblingStatementNodeByOffset (node: ESTree.Statement, offset: number): TStatement | null {
-        const scopeNode: TNodeWithScope = NodeUtils.getScopeOfNode(node);
+    private static getSiblingStatementByOffset (statement: ESTree.Statement, offset: number): TStatement | null {
+        const scopeNode: TNodeWithScope = NodeUtils.getScopeOfNode(statement);
         const scopeBody: TStatement[] = !NodeGuards.isSwitchCaseNode(scopeNode)
             ? scopeNode.body
             : scopeNode.consequent;
-        const indexInScope: number = scopeBody.indexOf(node);
+        const indexInScope: number = scopeBody.indexOf(statement);
 
         return scopeBody[indexInScope + offset] || null;
     }

+ 21 - 19
src/options/ValidationErrorsFormatter.ts

@@ -1,35 +1,37 @@
 import { ValidationError } from 'class-validator';
 
+import { TObject } from '../types/TObject';
+
 export class ValidationErrorsFormatter {
     /**
-     * @param {ValidationError[]} validationErrors
+     * @param {ValidationError[]} errors
      * @returns {string}
      */
-    public static format (validationErrors: ValidationError[]): string {
-        const errorsArray: string[] = [];
-
-        for (const error of validationErrors) {
-            errorsArray.push(ValidationErrorsFormatter.formatError(error));
-        }
-
-        return errorsArray.join('\n');
+    public static format (errors: ValidationError[]): string {
+        return errors
+            .reduce(
+                (errorMessages: string[], error: ValidationError) => ([
+                    ...errorMessages,
+                    ValidationErrorsFormatter.formatWithNestedConstraints(error)
+                ]),
+                []
+            )
+            .join('\n');
     }
 
     /**
-     * @param {ValidationError} validationError
+     * @param {ValidationError} error
      * @returns {string}
      */
-    private static formatError (validationError: ValidationError): string {
-        const constraints: {[type: string]: string} = validationError.constraints;
-
-        let errorString: string = `\`${validationError.property}\` errors:\n`;
+    private static formatWithNestedConstraints (error: ValidationError): string {
+        const constraints: TObject<string> = error.constraints;
 
-        Object
+        const rootError: string = `\`${error.property}\` errors:\n`;
+        const nestedErrors: string = Object
             .keys(constraints)
-            .forEach((constraint: string) => {
-                errorString += `    - ${constraints[constraint]}\n`;
-            });
+            .map((constraint: string) => `    - ${constraints[constraint]}\n`)
+            .join();
 
-        return errorString;
+        return `${rootError}${nestedErrors}`;
     }
 }

+ 1 - 1
src/options/normalizer-rules/DomainLockRule.ts

@@ -13,7 +13,7 @@ export const DomainLockRule: TOptionsNormalizerRule = (options: IOptions): IOpti
         const normalizedDomains: string[] = [];
 
         for (const domain of options.domainLock) {
-            normalizedDomains.push(Utils.extractDomainFromUrl(domain));
+            normalizedDomains.push(Utils.extractDomainFrom(domain));
         }
 
         options = {

+ 1 - 1
src/storages/string-array/StringArrayStorage.ts

@@ -66,7 +66,7 @@ export class StringArrayStorage extends ArrayStorage <string> {
      * @param {number} rotationValue
      */
     public rotateArray (rotationValue: number): void {
-        this.storage = this.arrayUtils.arrayRotate(this.storage, rotationValue);
+        this.storage = this.arrayUtils.rotate(this.storage, rotationValue);
     }
 
     /**

+ 3 - 3
src/utils/ArrayUtils.ts

@@ -24,7 +24,7 @@ export class ArrayUtils implements IArrayUtils {
      * @param {number} length
      * @returns {number[]}
      */
-    public arrayRange (length: number): number[] {
+    public createWithRange (length: number): number[] {
         const range: number[] = [];
 
         for (let i: number = 0; i < length; i++) {
@@ -39,7 +39,7 @@ export class ArrayUtils implements IArrayUtils {
      * @param {number} times
      * @returns {T[]}
      */
-    public arrayRotate <T> (array: T[], times: number): T[] {
+    public rotate <T> (array: T[], times: number): T[] {
         if (!array.length) {
             throw new ReferenceError(`Cannot rotate empty array.`);
         }
@@ -67,7 +67,7 @@ export class ArrayUtils implements IArrayUtils {
      * @param {T[]} array
      * @returns {T[]}
      */
-    public arrayShuffle <T> (array: T[]): T[] {
+    public shuffle <T> (array: T[]): T[] {
         const shuffledArray: T[] = [...array];
 
         for (let i: number = shuffledArray.length; i; i--) {

+ 19 - 0
src/utils/NumberUtils.ts

@@ -0,0 +1,19 @@
+export class NumberUtils {
+    /**
+     * @param {number} dec
+     * @returns {string}
+     */
+    public static toHex (dec: number): string {
+        const radix: number = 16;
+
+        return dec.toString(radix);
+    }
+
+    /**
+     * @param {number} number
+     * @returns {boolean}
+     */
+    public static isCeil (number: number): boolean {
+        return number % 1 === 0;
+    }
+}

+ 1 - 51
src/utils/Utils.ts

@@ -1,26 +1,14 @@
-import { JSFuck } from '../enums/JSFuck';
-
 export class Utils {
     /**
      * @type {string}
      */
     public static readonly hexadecimalPrefix: string = '0x';
 
-    /**
-     * @param {number} dec
-     * @returns {string}
-     */
-    public static decToHex (dec: number): string {
-        const radix: number = 16;
-
-        return dec.toString(radix);
-    }
-
     /**
      * @param {string} url
      * @returns {string}
      */
-    public static extractDomainFromUrl (url: string): string {
+    public static extractDomainFrom (url: string): string {
         let domain: string;
 
         if (url.indexOf('://') > -1 || url.indexOf('//') === 0) {
@@ -33,42 +21,4 @@ export class Utils {
 
         return domain;
     }
-
-    /**
-     * @param {number} number
-     * @returns {boolean}
-     */
-    public static isCeilNumber (number: number): boolean {
-        return number % 1 === 0;
-    }
-
-    /**
-     * @param {string} string
-     * @param {number} times
-     * @returns {string}
-     */
-    public static stringRotate (string: string, times: number): string {
-        if (!string) {
-            throw new ReferenceError(`Cannot rotate empty string.`);
-        }
-
-        for (let i: number = 0; i < times; i++) {
-            string = string[string.length - 1] + string.substring(0, string.length - 1);
-        }
-
-        return string;
-    }
-
-    /**
-     * @param {string} string
-     * @returns {string}
-     */
-    public static stringToJSFuck (string: string): string {
-        return Array
-            .from(string)
-            .map((character: string): string => {
-                return JSFuck[<keyof typeof JSFuck>character] || character;
-            })
-            .join(' + ');
-    }
 }

+ 1 - 1
test/functional-tests/analyzers/stack-trace-analyzer/StackTraceAnalyzer.spec.ts

@@ -149,7 +149,7 @@ function getObjectFunctionExpressionByName (astTree: ESTree.Node, objectName: st
 }
 
 describe('StackTraceAnalyzer', () => {
-    describe('extract (): IStackTraceData[]', () => {
+    describe('extract', () => {
         let stackTraceAnalyzer: IStackTraceAnalyzer,
             expectedStackTraceData: IStackTraceData[],
             stackTraceData: IStackTraceData[];

+ 1 - 1
test/functional-tests/cli/JavaScriptObfuscatorCLI.spec.ts

@@ -25,7 +25,7 @@ describe('JavaScriptObfuscatorCLI', function (): void {
     const configFilePath: string = `${configDirName}/${configFileName}`;
 
 
-    describe('run (): void', () => {
+    describe('run', () => {
         before(() => {
             mkdirp.sync(outputDirName);
         });

+ 1 - 1
test/functional-tests/javascript-obfuscator/JavaScriptObfuscator.spec.ts

@@ -16,7 +16,7 @@ import { getRegExpMatch } from '../../helpers/getRegExpMatch';
 import { readFileAsString } from '../../helpers/readFileAsString';
 
 describe('JavaScriptObfuscator', () => {
-    describe('obfuscate (sourceCode: string, customOptions?: IObfuscatorOptions): IObfuscationResult', () => {
+    describe('obfuscate', () => {
         describe('correct source code', () => {
             let obfuscatedCode: string,
                 sourceMap: string;

+ 1 - 1
test/functional-tests/node-transformers/control-flow-transformers/block-statement-control-flow-transformer/BlockStatementControlFlowTransformer.spec.ts

@@ -20,7 +20,7 @@ const getStatementRegExp: (hexNumber: string) => RegExp = (hexNumber) => {
 describe('BlockStatementControlFlowTransformer', function () {
     this.timeout(100000);
 
-    describe('transformNode (blockStatementNode: ESTree.BlockStatement): ESTree.Node', () => {
+    describe('transformNode', () => {
         describe('Variant #1: 5 simple statements', () => {
             let obfuscatedCode: string;
 

+ 1 - 1
test/functional-tests/node-transformers/control-flow-transformers/control-flow-replacers/binary-expression-control-flow-replacer/BinaryExpressionControlFlowReplacer.spec.ts

@@ -11,7 +11,7 @@ import { JavaScriptObfuscator } from '../../../../../../src/JavaScriptObfuscator
 describe('BinaryExpressionControlFlowReplacer', function () {
     this.timeout(100000);
 
-    describe('replace (binaryExpressionNode, parentNode, controlFlowStorage)', () => {
+    describe('replace', () => {
         describe('Variant #1 - single binary expression', () => {
             const controlFlowStorageCallRegExp: RegExp = /var *_0x([a-f0-9]){4,6} *= *_0x([a-f0-9]){4,6}\['\w{5}'\]\(0x1, *0x2\);/;
 

+ 1 - 1
test/functional-tests/node-transformers/control-flow-transformers/control-flow-replacers/call-expression-control-flow-replacer/CallExpressionControlFlowReplacer.spec.ts

@@ -11,7 +11,7 @@ import { JavaScriptObfuscator } from '../../../../../../src/JavaScriptObfuscator
 describe('CallExpressionControlFlowReplacer', function () {
     this.timeout(100000);
 
-    describe('replace (callExpressionNode, parentNode, controlFlowStorage)', () => {
+    describe('replace', () => {
         describe('Variant #1 - single call expression', () => {
             const controlFlowStorageCallRegExp: RegExp = /var *_0x([a-f0-9]){4,6} *= *_0x([a-f0-9]){4,6}\['\w{5}'\]\(_0x([a-f0-9]){4,6}, *0x1, *0x2\);/;
 

+ 1 - 1
test/functional-tests/node-transformers/control-flow-transformers/control-flow-replacers/logical-expression-control-flow-replacer/LogicalExpressionControlFlowReplacer.spec.ts

@@ -11,7 +11,7 @@ import { JavaScriptObfuscator } from '../../../../../../src/JavaScriptObfuscator
 describe('LogicalExpressionControlFlowReplacer', function () {
     this.timeout(100000);
 
-    describe('replace (logicalExpressionNode, parentNode, controlFlowStorage)', () => {
+    describe('replace', () => {
         describe('Variant #1 - single logical expression', () => {
             const controlFlowStorageCallRegExp: RegExp = /var *_0x([a-f0-9]){4,6} *= *_0x([a-f0-9]){4,6}\['\w{5}'\]\(!!\[\], *!\[\]\);/;
 

+ 1 - 1
test/functional-tests/node-transformers/control-flow-transformers/control-flow-replacers/string-litertal-control-flow-replacer/StringLiteralControlFlowReplacer.spec.ts

@@ -9,7 +9,7 @@ import { readFileAsString } from '../../../../../helpers/readFileAsString';
 import { JavaScriptObfuscator } from '../../../../../../src/JavaScriptObfuscatorFacade';
 
 describe('StringLiteralControlFlowReplacer', () => {
-    describe('replace (literalNode, parentNode, controlFlowStorage)', () => {
+    describe('replace', () => {
         const controlFlowStorageStringLiteralRegExp: RegExp = /var *_0x([a-f0-9]){4,6} *= *\{'\w{5}' *: *'test'\};/;
         const controlFlowStorageCallRegExp: RegExp = /var *_0x([a-f0-9]){4,6} *= *_0x([a-f0-9]){4,6}\['\w{5}'\];/;
 

+ 1 - 1
test/functional-tests/node-transformers/control-flow-transformers/function-control-flow-transformer/FunctionControlFlowTransformer.spec.ts

@@ -27,7 +27,7 @@ describe('FunctionControlFlowTransformer', function () {
         `\\};` +
     ``;
 
-    describe('transformNode (functionNode: ESTree.Function): ESTree.Node', () => {
+    describe('transformNode', () => {
         describe('Variant #1 - single `control flow storage` node with single item', () => {
             const regexp: RegExp = new RegExp(rootControlFlowStorageNodeMatch);
 

+ 23 - 0
test/functional-tests/node-transformers/converting-transformers/object-expression-keys-transformer/ObjectExpressionKeysTransformer.spec.ts

@@ -372,5 +372,28 @@ describe('ObjectExpressionKeysTransformer', () => {
                 assert.match(obfuscatedCode,  regExp);
             });
         });
+
+        describe('Variant #2: empty object expression', () => {
+            const match: string = `var *${variableMatch} *= *{};`;
+            const regExp: RegExp = new RegExp(match);
+
+            let obfuscatedCode: string;
+
+            before(() => {
+                const code: string = readFileAsString(__dirname + '/fixtures/empty-object-expression.js');
+                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+                    code,
+                    {
+                        ...NO_ADDITIONAL_NODES_PRESET
+                    }
+                );
+
+                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+            });
+
+            it('shouldn\'t transform object keys', () => {
+                assert.match(obfuscatedCode,  regExp);
+            });
+        });
     });
 });

+ 3 - 0
test/functional-tests/node-transformers/converting-transformers/object-expression-keys-transformer/fixtures/empty-object-expression.js

@@ -0,0 +1,3 @@
+(function(){
+    var object = {};
+})();

+ 1 - 1
test/functional-tests/node-transformers/dead-code-injection-transformers/DeadCodeInjectionTransformer.spec.ts

@@ -15,7 +15,7 @@ describe('DeadCodeInjectionTransformer', () => {
     const variableMatch: string = '_0x([a-f0-9]){4,6}';
     const hexMatch: string = '0x[a-f0-9]';
 
-    describe('transformNode (programNode: ESTree.Program, parentNode: ESTree.Node): ESTree.Node', function () {
+    describe('transformNode', function () {
         this.timeout(100000);
 
         describe('Variant #1 - 5 simple block statements', () => {

+ 1 - 1
test/functional-tests/node-transformers/obfuscating-transformers/catch-clause-transformer/CatchClauseTransformer.spec.ts

@@ -12,7 +12,7 @@ import { JavaScriptObfuscator } from '../../../../../src/JavaScriptObfuscatorFac
 describe('CatchClauseTransformer', () => {
     let obfuscatedCode: string;
 
-    describe('changeControlFlow (catchClauseNode: ESTree.CatchClause): void', () => {
+    describe('transformNode', () => {
         const paramNameRegExp: RegExp = /catch *\((_0x([a-f0-9]){4,6})\) *\{/;
         const bodyParamNameRegExp: RegExp = /console\['log'\]\((_0x([a-f0-9]){4,6})\);/;
 

+ 1 - 1
test/functional-tests/node-transformers/obfuscating-transformers/labeled-statement-transformer/LabeledStatementTransformer.spec.ts

@@ -10,7 +10,7 @@ import { readFileAsString } from '../../../../helpers/readFileAsString';
 import { JavaScriptObfuscator } from '../../../../../src/JavaScriptObfuscatorFacade';
 
 describe('LabeledStatementTransformer', () => {
-    describe('changeControlFlow (labeledStatementNode: ESTree.LabeledStatement): void', () => {
+    describe('transformNode', () => {
         const labeledStatementRegExp: RegExp = /(_0x([a-f0-9]){4,6}): *for/;
         const continueStatementRegExp: RegExp = /continue *(_0x([a-f0-9]){4,6});/;
         const breakStatementRegExp: RegExp = /break *(_0x([a-f0-9]){4,6});/;

+ 1 - 1
test/functional-tests/node-transformers/preparing-transformers/obfuscating-guards/black-list-obfuscating-guard/BlackListObfuscatingGuard.spec.ts

@@ -9,7 +9,7 @@ import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../../src/options/preset
 import { readFileAsString } from '../../../../../helpers/readFileAsString';
 
 describe('BlackListObfuscatingGuard', () => {
-    describe('check (node: ESTree.Node): boolean', () => {
+    describe('check', () => {
         describe('`\'use strict\';` operator', () => {
             const useStrictOperatorRegExp: RegExp = /'use *strict';/;
             const stringArrayLatinRegExp: RegExp = /var _0x(\w){4} *= *\['abc'\];/;

+ 1 - 1
test/functional-tests/node-transformers/preparing-transformers/obfuscating-guards/conditional-comment-obfuscating-guard/ConditionalCommentObfuscatingGuard.spec.ts

@@ -9,7 +9,7 @@ import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../../src/options/preset
 import { readFileAsString } from '../../../../../helpers/readFileAsString';
 
 describe('ConditionalCommentObfuscatingGuard', () => {
-    describe('check (node: ESTree.Node): boolean', () => {
+    describe('check', () => {
         describe('Variant #1: `disable` conditional comment', () => {
             const obfuscatedVariableDeclarationRegExp: RegExp = /var *_0x([a-f0-9]){4,6} *= *0x1;/;
             const ignoredVariableDeclarationRegExp: RegExp = /var *bar *= *2;/;

+ 1 - 1
test/functional-tests/options/OptionsNormalizer.spec.ts

@@ -34,7 +34,7 @@ function getNormalizedOptions (optionsPreset: TInputOptions): TInputOptions {
 }
 
 describe('OptionsNormalizer', () => {
-    describe('normalize (options: IObfuscatorOptions): IObfuscatorOptions', () => {
+    describe('normalize', () => {
         let optionsPreset: TInputOptions,
             expectedOptionsPreset: TInputOptions;
 

+ 1 - 1
test/functional-tests/templates/GlobalVariableNoEvalTemplate.spec.ts

@@ -6,7 +6,7 @@ import { assert } from 'chai';
 
 import { GlobalVariableNoEvalTemplate } from '../../../src/templates/GlobalVariableNoEvalTemplate';
 
-describe('GlobalVariableNoEvalTemplate (): string', () => {
+describe('GlobalVariableNoEvalTemplate', () => {
     describe('Variant #1: simple', () => {
         const expectedGlobalObject: NodeJS.Global = global;
 

+ 1 - 1
test/functional-tests/templates/debug-protection-nodes/DebugProtectionFunctionCallTemplate.spec.ts

@@ -30,7 +30,7 @@ function spawnThread(inputCallback: Function, threadCallback: Function, timeoutC
         });
 }
 
-describe('DebugProtectionFunctionCallTemplate (): string', () => {
+describe('DebugProtectionFunctionCallTemplate', () => {
     describe('Variant #1: correctly obfuscated code`', () => {
         const expectedEvaluationResult: number = 1;
 

+ 1 - 1
test/functional-tests/templates/domain-lock-nodes/DomainLockNodeTemplate.spec.ts

@@ -40,7 +40,7 @@ function getFunctionFromTemplate (templateData: any, callsControllerFunctionName
     `)();
 }
 
-describe('DomainLockNodeTemplate (): string', () => {
+describe('DomainLockNodeTemplate', () => {
     const singleNodeCallControllerFunctionName: string = 'callsController';
 
     let cryptUtils: ICryptUtils;

+ 1 - 1
test/functional-tests/templates/string-array-nodes/StringArrayCallsWrapperNodeTemplate.spec.ts

@@ -19,7 +19,7 @@ import { StringArrayRc4DecodeNodeTemplate } from '../../../../src/templates/stri
 
 import { InversifyContainerFacade } from '../../../../src/container/InversifyContainerFacade';
 
-describe('StringArrayCallsWrapperNodeTemplate (): string', () => {
+describe('StringArrayCallsWrapperNodeTemplate', () => {
     const stringArrayName: string = 'stringArrayName';
     const stringArrayCallsWrapperName: string = 'stringArrayCallsWrapperName';
 

+ 1 - 0
test/index.spec.ts

@@ -33,6 +33,7 @@ import './unit-tests/storages/MapStorage.spec';
 import './unit-tests/utils/ArrayUtils.spec';
 import './unit-tests/utils/CryptUtils.spec';
 import './unit-tests/utils/EscapeSequenceEncoder.spec';
+import './unit-tests/utils/NumberUtils.spec';
 import './unit-tests/utils/Utils.spec';
 
 /**

+ 1 - 1
test/unit-tests/analyzers/stack-trace-analyzer/StackTraceAnalyzer.spec.ts

@@ -3,7 +3,7 @@ import { assert } from 'chai';
 import { StackTraceAnalyzer } from '../../../../src/analyzers/stack-trace-analyzer/StackTraceAnalyzer';
 
 describe('StackTraceAnalyzer', () => {
-    describe('getLimitIndex (blockScopeBodyLength: number): number', () => {
+    describe('getLimitIndex', () => {
         let limitIndex: number;
 
         describe('Variant #1: length - 10000', () => {

+ 27 - 29
test/unit-tests/cli/sanitizers/ArraySanitizer.spec.ts

@@ -3,47 +3,45 @@ import { assert } from 'chai';
 import { ArraySanitizer } from '../../../../src/cli/sanitizers/ArraySanitizer';
 
 describe('ArraySanitizer', () => {
-    describe('ArraySanitizer: TCLISanitizer = (value: string): string[]', () => {
-        describe('Variant #1: input value `foo`', () => {
-            const inputValue: string = 'foo';
-            const expectedValue: string[] = ['foo'];
+    describe('Variant #1: input value `foo`', () => {
+        const inputValue: string = 'foo';
+        const expectedValue: string[] = ['foo'];
 
-            let value: string[];
+        let value: string[];
 
-            before(() => {
-                value = ArraySanitizer(inputValue);
-            });
+        before(() => {
+            value = ArraySanitizer(inputValue);
+        });
 
-            it('should sanitize value', () => {
-                assert.deepEqual(value, expectedValue);
-            });
+        it('should sanitize value', () => {
+            assert.deepEqual(value, expectedValue);
         });
+    });
 
-        describe('Variant #2: input value `foo, bar`', () => {
-            const inputValue: string = 'foo, bar';
-            const expectedValue: string[] = ['foo', 'bar'];
+    describe('Variant #2: input value `foo, bar`', () => {
+        const inputValue: string = 'foo, bar';
+        const expectedValue: string[] = ['foo', 'bar'];
 
-            let value: string[];
+        let value: string[];
 
-            before(() => {
-                value = ArraySanitizer(inputValue);
-            });
+        before(() => {
+            value = ArraySanitizer(inputValue);
+        });
 
-            it('should sanitize value', () => {
-                assert.deepEqual(value, expectedValue);
-            });
+        it('should sanitize value', () => {
+            assert.deepEqual(value, expectedValue);
         });
+    });
 
-        describe('Variant #3: input value `foo,`', () => {
-            const inputValue: string = 'foo,';
+    describe('Variant #3: input value `foo,`', () => {
+        const inputValue: string = 'foo,';
 
-            const testFunc: () => void = () => {
-                ArraySanitizer(inputValue);
-            };
+        const testFunc: () => void = () => {
+            ArraySanitizer(inputValue);
+        };
 
-            it('should sanitize value', () => {
-                assert.throw(testFunc, SyntaxError);
-            });
+        it('should sanitize value', () => {
+            assert.throw(testFunc, SyntaxError);
         });
     });
 });

+ 39 - 41
test/unit-tests/cli/sanitizers/BooleanSanitizer.spec.ts

@@ -4,65 +4,63 @@ import { BooleanSanitizer } from '../../../../src/cli/sanitizers/BooleanSanitize
 
 
 describe('BooleanSanitizer', () => {
-    describe('BooleanSanitizer: TCLISanitizer = (value: string): boolean', () => {
-        describe('Variant #1: input value `true`', () => {
-            const inputValue: string = 'true';
-            const expectedValue: boolean = true;
+    describe('Variant #1: input value `true`', () => {
+        const inputValue: string = 'true';
+        const expectedValue: boolean = true;
 
-            let value: boolean;
+        let value: boolean;
 
-            before(() => {
-                value = BooleanSanitizer(inputValue);
-            });
+        before(() => {
+            value = BooleanSanitizer(inputValue);
+        });
 
-            it('should sanitize value', () => {
-                assert.equal(value, expectedValue);
-            });
+        it('should sanitize value', () => {
+            assert.equal(value, expectedValue);
         });
+    });
 
-        describe('Variant #2: input value `1`', () => {
-            const inputValue: string = '1';
-            const expectedValue: boolean = true;
+    describe('Variant #2: input value `1`', () => {
+        const inputValue: string = '1';
+        const expectedValue: boolean = true;
 
-            let value: boolean;
+        let value: boolean;
 
-            before(() => {
-                value = BooleanSanitizer(inputValue);
-            });
+        before(() => {
+            value = BooleanSanitizer(inputValue);
+        });
 
-            it('should sanitize value', () => {
-                assert.equal(value, expectedValue);
-            });
+        it('should sanitize value', () => {
+            assert.equal(value, expectedValue);
         });
+    });
 
-        describe('Variant #3: input value `false`', () => {
-            const inputValue: string = 'false';
-            const expectedValue: boolean = false;
+    describe('Variant #3: input value `false`', () => {
+        const inputValue: string = 'false';
+        const expectedValue: boolean = false;
 
-            let value: boolean;
+        let value: boolean;
 
-            before(() => {
-                value = BooleanSanitizer(inputValue);
-            });
+        before(() => {
+            value = BooleanSanitizer(inputValue);
+        });
 
-            it('should sanitize value', () => {
-                assert.equal(value, expectedValue);
-            });
+        it('should sanitize value', () => {
+            assert.equal(value, expectedValue);
         });
+    });
 
-        describe('Variant #4: input value `foo`', () => {
-            const inputValue: string = 'foo';
-            const expectedValue: boolean = false;
+    describe('Variant #4: input value `foo`', () => {
+        const inputValue: string = 'foo';
+        const expectedValue: boolean = false;
 
-            let value: boolean;
+        let value: boolean;
 
-            before(() => {
-                value = BooleanSanitizer(inputValue);
-            });
+        before(() => {
+            value = BooleanSanitizer(inputValue);
+        });
 
-            it('should sanitize value', () => {
-                assert.equal(value, expectedValue);
-            });
+        it('should sanitize value', () => {
+            assert.equal(value, expectedValue);
         });
     });
 });

+ 18 - 20
test/unit-tests/cli/sanitizers/IdentifierNamesGeneratorSanitizer.spec.ts

@@ -3,34 +3,32 @@ import { assert } from 'chai';
 import { IdentifierNamesGeneratorSanitizer } from '../../../../src/cli/sanitizers/IdentifierNamesGeneratorSanitizer';
 
 describe('IdentifierNamesGeneratorSanitizer', () => {
-    describe('IdentifierNamesGeneratorSanitizer: TCLISanitizer = (value: string): string', () => {
-        describe('Variant #1: valid identifier names generator', () => {
-            const inputValue: string = 'mangled';
-            const expectedValue: string = inputValue;
+    describe('Variant #1: valid identifier names generator', () => {
+        const inputValue: string = 'mangled';
+        const expectedValue: string = inputValue;
 
-            let value: string;
+        let value: string;
 
-            before(() => {
-                value = IdentifierNamesGeneratorSanitizer(inputValue);
-            });
+        before(() => {
+            value = IdentifierNamesGeneratorSanitizer(inputValue);
+        });
 
-            it('should sanitize value', () => {
-                assert.equal(value, expectedValue);
-            });
+        it('should sanitize value', () => {
+            assert.equal(value, expectedValue);
         });
+    });
 
-        describe('Variant #2: invalid identifier names generator', () => {
-            const inputValue: string = 'foo';
+    describe('Variant #2: invalid identifier names generator', () => {
+        const inputValue: string = 'foo';
 
-            let testFunc: () => void;
+        let testFunc: () => void;
 
-            before(() => {
-                testFunc = () => IdentifierNamesGeneratorSanitizer(inputValue);
-            });
+        before(() => {
+            testFunc = () => IdentifierNamesGeneratorSanitizer(inputValue);
+        });
 
-            it('should throw error', () => {
-                assert.throw(testFunc, ReferenceError);
-            });
+        it('should throw error', () => {
+            assert.throw(testFunc, ReferenceError);
         });
     });
 });

+ 18 - 20
test/unit-tests/cli/sanitizers/ObfuscationTargetSanitizer.spec.ts

@@ -3,34 +3,32 @@ import { assert } from 'chai';
 import { ObfuscationTargetSanitizer } from '../../../../src/cli/sanitizers/ObfuscatingTargetSanitizer';
 
 describe('ObfuscationTargetSanitizer', () => {
-    describe('ObfuscationTargetSanitizer: TCLISanitizer = (value: string): string', () => {
-        describe('Variant #1: valid obfuscation target', () => {
-            const inputValue: string = 'browser';
-            const expectedValue: string = inputValue;
+    describe('Variant #1: valid obfuscation target', () => {
+        const inputValue: string = 'browser';
+        const expectedValue: string = inputValue;
 
-            let value: string;
+        let value: string;
 
-            before(() => {
-                value = ObfuscationTargetSanitizer(inputValue);
-            });
+        before(() => {
+            value = ObfuscationTargetSanitizer(inputValue);
+        });
 
-            it('should sanitize value', () => {
-                assert.equal(value, expectedValue);
-            });
+        it('should sanitize value', () => {
+            assert.equal(value, expectedValue);
         });
+    });
 
-        describe('Variant #2: invalid obfuscation target', () => {
-            const inputValue: string = 'foo';
+    describe('Variant #2: invalid obfuscation target', () => {
+        const inputValue: string = 'foo';
 
-            let testFunc: () => void;
+        let testFunc: () => void;
 
-            before(() => {
-                testFunc = () => ObfuscationTargetSanitizer(inputValue);
-            });
+        before(() => {
+            testFunc = () => ObfuscationTargetSanitizer(inputValue);
+        });
 
-            it('should throw error', () => {
-                assert.throw(testFunc, ReferenceError);
-            });
+        it('should throw error', () => {
+            assert.throw(testFunc, ReferenceError);
         });
     });
 });

+ 18 - 20
test/unit-tests/cli/sanitizers/SourceMapModeSanitizer.spec.ts

@@ -3,34 +3,32 @@ import { assert } from 'chai';
 import { SourceMapModeSanitizer } from '../../../../src/cli/sanitizers/SourceMapModeSanitizer';
 
 describe('SourceMapModeSanitizer', () => {
-    describe('SourceMapModeSanitizer: TCLISanitizer = (value: string): string', () => {
-        describe('Variant #1: valid source map mode', () => {
-            const inputValue: string = 'inline';
-            const expectedValue: string = inputValue;
+    describe('Variant #1: valid source map mode', () => {
+        const inputValue: string = 'inline';
+        const expectedValue: string = inputValue;
 
-            let value: string;
+        let value: string;
 
-            before(() => {
-                value = SourceMapModeSanitizer(inputValue);
-            });
+        before(() => {
+            value = SourceMapModeSanitizer(inputValue);
+        });
 
-            it('should sanitize value', () => {
-                assert.equal(value, expectedValue);
-            });
+        it('should sanitize value', () => {
+            assert.equal(value, expectedValue);
         });
+    });
 
-        describe('Variant #2: invalid source map mode', () => {
-            const inputValue: string = 'foo';
+    describe('Variant #2: invalid source map mode', () => {
+        const inputValue: string = 'foo';
 
-            let testFunc: () => void;
+        let testFunc: () => void;
 
-            before(() => {
-                testFunc = () => SourceMapModeSanitizer(inputValue);
-            });
+        before(() => {
+            testFunc = () => SourceMapModeSanitizer(inputValue);
+        });
 
-            it('should throw error', () => {
-                assert.throw(testFunc, ReferenceError);
-            });
+        it('should throw error', () => {
+            assert.throw(testFunc, ReferenceError);
         });
     });
 });

+ 49 - 51
test/unit-tests/cli/sanitizers/StringArrayEncodingSanitizer.spec.ts

@@ -7,80 +7,78 @@ import { StringArrayEncoding } from '../../../../src/enums/StringArrayEncoding';
 import { StringArrayEncodingSanitizer } from '../../../../src/cli/sanitizers/StringArrayEncodingSanitizer';
 
 describe('StringArrayEncodingSanitizer', () => {
-    describe('StringArrayEncodingSanitizer: TCLISanitizer = (value: string): TStringArrayEncoding', () => {
-        describe('Variant #1: string array encoding `base64`', () => {
-            const inputValue: string = 'base64';
-            const expectedValue: TStringArrayEncoding = true;
+    describe('Variant #1: string array encoding `base64`', () => {
+        const inputValue: string = 'base64';
+        const expectedValue: TStringArrayEncoding = true;
 
-            let value: TStringArrayEncoding;
+        let value: TStringArrayEncoding;
 
-            before(() => {
-                value = StringArrayEncodingSanitizer(inputValue);
-            });
+        before(() => {
+            value = StringArrayEncodingSanitizer(inputValue);
+        });
 
-            it('should sanitize value', () => {
-                assert.equal(value, expectedValue);
-            });
+        it('should sanitize value', () => {
+            assert.equal(value, expectedValue);
         });
+    });
 
-        describe('Variant #2: string array encoding `true`', () => {
-            const inputValue: string = 'true';
-            const expectedValue: TStringArrayEncoding = true;
+    describe('Variant #2: string array encoding `true`', () => {
+        const inputValue: string = 'true';
+        const expectedValue: TStringArrayEncoding = true;
 
-            let value: TStringArrayEncoding;
+        let value: TStringArrayEncoding;
 
-            before(() => {
-                value = StringArrayEncodingSanitizer(inputValue);
-            });
+        before(() => {
+            value = StringArrayEncodingSanitizer(inputValue);
+        });
 
-            it('should sanitize value', () => {
-                assert.equal(value, expectedValue);
-            });
+        it('should sanitize value', () => {
+            assert.equal(value, expectedValue);
         });
+    });
 
-        describe('Variant #3: string array encoding `1`', () => {
-            const inputValue: string = '1';
-            const expectedValue: TStringArrayEncoding = true;
+    describe('Variant #3: string array encoding `1`', () => {
+        const inputValue: string = '1';
+        const expectedValue: TStringArrayEncoding = true;
 
-            let value: TStringArrayEncoding;
+        let value: TStringArrayEncoding;
 
-            before(() => {
-                value = StringArrayEncodingSanitizer(inputValue);
-            });
+        before(() => {
+            value = StringArrayEncodingSanitizer(inputValue);
+        });
 
-            it('should sanitize value', () => {
-                assert.equal(value, expectedValue);
-            });
+        it('should sanitize value', () => {
+            assert.equal(value, expectedValue);
         });
+    });
 
-        describe('Variant #4: string array encoding `rc4`', () => {
-            const inputValue: string = 'rc4';
-            const expectedValue: TStringArrayEncoding = StringArrayEncoding.Rc4;
+    describe('Variant #4: string array encoding `rc4`', () => {
+        const inputValue: string = 'rc4';
+        const expectedValue: TStringArrayEncoding = StringArrayEncoding.Rc4;
 
-            let value: TStringArrayEncoding;
+        let value: TStringArrayEncoding;
 
-            before(() => {
-                value = StringArrayEncodingSanitizer(inputValue);
-            });
+        before(() => {
+            value = StringArrayEncodingSanitizer(inputValue);
+        });
 
-            it('should sanitize value', () => {
-                assert.equal(value, expectedValue);
-            });
+        it('should sanitize value', () => {
+            assert.equal(value, expectedValue);
         });
+    });
 
-        describe('Variant #5: string array encoding `foo`', () => {
-            const inputValue: string = 'foo';
-            const expectedValue: TStringArrayEncoding = false;
+    describe('Variant #5: string array encoding `foo`', () => {
+        const inputValue: string = 'foo';
+        const expectedValue: TStringArrayEncoding = false;
 
-            let value: TStringArrayEncoding;
+        let value: TStringArrayEncoding;
 
-            before(() => {
-                value = StringArrayEncodingSanitizer(inputValue);
-            });
+        before(() => {
+            value = StringArrayEncodingSanitizer(inputValue);
+        });
 
-            it('should sanitize value', () => {
-                assert.equal(value, expectedValue);
-            });
+        it('should sanitize value', () => {
+            assert.equal(value, expectedValue);
         });
     });
 });

+ 3 - 3
test/unit-tests/cli/utils/CLIUtils.spec.ts

@@ -5,7 +5,7 @@ import { TInputOptions } from '../../../../src/types/options/TInputOptions';
 import { CLIUtils } from '../../../../src/cli/utils/CLIUtils';
 
 describe('CLIUtils', () => {
-    describe('getOutputCodePath (inputPath: string): string', () => {
+    describe('getOutputCodePath', () => {
         describe('Variant #1: base input path', () => {
             let expectedOutputPath: string = 'test/input/test-obfuscated.js',
                 inputPath: string = 'test/input/test.js';
@@ -25,7 +25,7 @@ describe('CLIUtils', () => {
         });
     });
 
-    describe('getOutputSourceMapPath (outputCodePath: string): string', () => {
+    describe('getOutputSourceMapPath', () => {
         let expectedOutputSourceMapPath: string = 'test/output/test.js.map',
             outputCodePath: string = 'test/output/test.js';
 
@@ -34,7 +34,7 @@ describe('CLIUtils', () => {
         });
     });
 
-    describe('getUserConfig (configPath: string): Object', () => {
+    describe('getUserConfig', () => {
         describe('Variant #1: valid config file path', () => {
             describe('Variant #1: js file with config', () => {
                 const configDirName: string = 'test/fixtures';

+ 1 - 1
test/unit-tests/cli/utils/SourceCodeReader.spec.ts

@@ -18,7 +18,7 @@ describe('SourceCodeReader', () => {
         mkdirp.sync(tmpDirectoryPath);
     });
 
-    describe('readSourceCode (inputPath: string): TSourceCodeData', () => {
+    describe('readSourceCode', () => {
         describe('Variant #1: input path is a file path', () => {
             describe('Variant #1: `inputPath` is a valid path', () => {
                 const tmpFileName: string = 'test.js';

+ 121 - 123
test/unit-tests/decorators/initializable/Initializable.spec.ts

@@ -6,195 +6,193 @@ import { initializable } from '../../../../src/decorators/Initializable';
 import { IInitializable } from '../../../../src/interfaces/IInitializable';
 
 describe('@initializable', () => {
-    describe('initializable (initializeMethodKey: string): any', () => {
-        describe('Variant #1: property was initialized', () => {
+    describe('Variant #1: property was initialized', () => {
+        const testFunc: () => void = () => {
+            class Foo implements IInitializable {
+                @initializable()
+                public property!: string;
+
+                public initialize (property: string): void {
+                    this.property = property;
+                }
+            }
+
+            const foo: Foo = new Foo();
+
+            foo.initialize('baz');
+
+            foo.property;
+        };
+
+        it('shouldn\'t throws an errors if property was initialized', () => {
+            assert.doesNotThrow(testFunc, Error);
+        });
+    });
+
+    describe('Variant #2: `initialize` method should be called first', () => {
+        describe('Variant #1: `initialize` method was called first', () => {
             const testFunc: () => void = () => {
-                class Foo implements IInitializable {
+                class Foo {
                     @initializable()
                     public property!: string;
 
                     public initialize (property: string): void {
                         this.property = property;
                     }
+
+                    public bar (): void {}
                 }
 
                 const foo: Foo = new Foo();
 
                 foo.initialize('baz');
-
-                foo.property;
+                foo.bar();
             };
 
-            it('shouldn\'t throws an errors if property was initialized', () => {
-                assert.doesNotThrow(testFunc, Error);
+            it('shouldn\'t throw an error if `initialize` method was called first', () => {
+                assert.doesNotThrow(testFunc, /Class should be initialized/);
             });
         });
 
-        describe('Variant #2: `initialize` method should be called first', () => {
-            describe('Variant #1: `initialize` method was called first', () => {
-                const testFunc: () => void = () => {
-                    class Foo {
-                        @initializable()
-                        public property!: string;
-
-                        public initialize (property: string): void {
-                            this.property = property;
-                        }
-
-                        public bar (): void {}
-                    }
-
-                    const foo: Foo = new Foo();
-
-                    foo.initialize('baz');
-                    foo.bar();
-                };
-
-                it('shouldn\'t throw an error if `initialize` method was called first', () => {
-                    assert.doesNotThrow(testFunc, /Class should be initialized/);
-                });
-            });
-
-            describe('Variant #2: other method was called inside `initialize` method with initialization of the property', () => {
-                const testFunc: () => void = () => {
-                    class Foo {
-                        @initializable()
-                        public property!: string;
-
-                        public initialize (property: string): void {
-                            this.innerInitialize(property);
-                        }
+        describe('Variant #2: other method was called inside `initialize` method with initialization of the property', () => {
+            const testFunc: () => void = () => {
+                class Foo {
+                    @initializable()
+                    public property!: string;
 
-                        public innerInitialize (property: string): void {
-                            this.property = property;
-                        }
+                    public initialize (property: string): void {
+                        this.innerInitialize(property);
                     }
 
-                    const foo: Foo = new Foo();
-
-                    foo.initialize('baz');
-                };
-
-                it('shouldn\'t throw an error if other method was called inside `initialize` method', () => {
-                    assert.doesNotThrow(testFunc, /Class should be initialized/);
-                });
-            });
-
-            describe('Variant #3: other method was called inside `initialize` method without initialization of the property', () => {
-                const testFunc: () => void = () => {
-                    class Foo {
-                        @initializable()
-                        public property!: string;
-
-                        public initialize (property: string): void {
-                            this.innerInitialize(property);
-                        }
-
-                        public innerInitialize (property: string): void {
-                        }
+                    public innerInitialize (property: string): void {
+                        this.property = property;
                     }
+                }
 
-                    const foo: Foo = new Foo();
+                const foo: Foo = new Foo();
 
-                    foo.initialize('baz');
-                };
+                foo.initialize('baz');
+            };
 
-                it('should throws an error if other method was called inside `initialize` method without initialization of the property', () => {
-                    assert.throws(testFunc, /Property `property` is not initialized/);
-                });
+            it('shouldn\'t throw an error if other method was called inside `initialize` method', () => {
+                assert.doesNotThrow(testFunc, /Class should be initialized/);
             });
+        });
 
-            describe('Variant #4: `initialize` method wasn\'t called first', () => {
-                const testFunc: () => void = () => {
-                    class Foo {
-                        @initializable()
-                        public property!: string;
-
-                        public initialize (property: string): void {
-                            this.property = property;
-                        }
+        describe('Variant #3: other method was called inside `initialize` method without initialization of the property', () => {
+            const testFunc: () => void = () => {
+                class Foo {
+                    @initializable()
+                    public property!: string;
 
-                        public bar (): void {}
+                    public initialize (property: string): void {
+                        this.innerInitialize(property);
                     }
 
-                    const foo: Foo = new Foo();
-
-                    foo.bar();
-                    foo.initialize('baz');
-                };
-
-                it('should throws an error if `initialize` method wasn\'t called first', () => {
-                    assert.throws(testFunc, /Class should be initialized/);
-                });
-            });
-
-            describe('Variant #5: `initialize` method wasn\'t called', () => {
-                const testFunc: () => void = () => {
-                    class Foo {
-                        @initializable()
-                        public property!: string;
-
-                        public initialize (property: string): void {
-                            this.property = property;
-                        }
-
-                        public bar (): void {}
+                    public innerInitialize (property: string): void {
                     }
+                }
 
-                    const foo: Foo = new Foo();
+                const foo: Foo = new Foo();
 
-                    foo.bar();
-                };
+                foo.initialize('baz');
+            };
 
-                it('should throws an error if `initialize` method wasn\'t called first', () => {
-                    assert.throws(testFunc, /Class should be initialized/);
-                });
+            it('should throws an error if other method was called inside `initialize` method without initialization of the property', () => {
+                assert.throws(testFunc, /Property `property` is not initialized/);
             });
         });
 
-        describe('Variant #3: property didn\'t initialized', () => {
+        describe('Variant #4: `initialize` method wasn\'t called first', () => {
             const testFunc: () => void = () => {
-                class Foo implements IInitializable {
+                class Foo {
                     @initializable()
                     public property!: string;
 
                     public initialize (property: string): void {
+                        this.property = property;
                     }
+
+                    public bar (): void {}
                 }
 
                 const foo: Foo = new Foo();
 
+                foo.bar();
                 foo.initialize('baz');
-
-                foo.property;
             };
 
-            it('should throws an error if property didn\'t initialized', () => {
-                assert.throws(testFunc, /Property `property` is not initialized/);
+            it('should throws an error if `initialize` method wasn\'t called first', () => {
+                assert.throws(testFunc, /Class should be initialized/);
             });
         });
 
-        describe('Variant #4: `initialize` method with custom name', () => {
+        describe('Variant #5: `initialize` method wasn\'t called', () => {
             const testFunc: () => void = () => {
                 class Foo {
-                    @initializable('bar')
+                    @initializable()
                     public property!: string;
 
                     public initialize (property: string): void {
                         this.property = property;
                     }
+
+                    public bar (): void {}
                 }
 
                 const foo: Foo = new Foo();
 
-                foo.initialize('baz');
-
-                foo.property;
+                foo.bar();
             };
 
-            it('should throws an error if `initialize` method with custom name wasn\'t found', () => {
-                assert.throws(testFunc, /method with initialization logic not found/);
+            it('should throws an error if `initialize` method wasn\'t called first', () => {
+                assert.throws(testFunc, /Class should be initialized/);
             });
         });
     });
+
+    describe('Variant #3: property didn\'t initialized', () => {
+        const testFunc: () => void = () => {
+            class Foo implements IInitializable {
+                @initializable()
+                public property!: string;
+
+                public initialize (property: string): void {
+                }
+            }
+
+            const foo: Foo = new Foo();
+
+            foo.initialize('baz');
+
+            foo.property;
+        };
+
+        it('should throws an error if property didn\'t initialized', () => {
+            assert.throws(testFunc, /Property `property` is not initialized/);
+        });
+    });
+
+    describe('Variant #4: `initialize` method with custom name', () => {
+        const testFunc: () => void = () => {
+            class Foo {
+                @initializable('bar')
+                public property!: string;
+
+                public initialize (property: string): void {
+                    this.property = property;
+                }
+            }
+
+            const foo: Foo = new Foo();
+
+            foo.initialize('baz');
+
+            foo.property;
+        };
+
+        it('should throws an error if `initialize` method with custom name wasn\'t found', () => {
+            assert.throws(testFunc, /method with initialization logic not found/);
+        });
+    });
 });

+ 1 - 1
test/unit-tests/generators/identifier-names-generators/HexadecimalIdentifierNamesGenerator.spec.ts

@@ -12,7 +12,7 @@ import { IdentifierNamesGenerator } from '../../../../src/enums/generators/ident
 import { InversifyContainerFacade } from '../../../../src/container/InversifyContainerFacade';
 
 describe('HexadecimalIdentifierNamesGenerator', () => {
-    describe('generate (): string', () => {
+    describe('generate', () => {
         let identifierNamesGenerator: IIdentifierNamesGenerator,
             hexadecimalIdentifierName: string,
             regExp: RegExp;

+ 1 - 1
test/unit-tests/generators/identifier-names-generators/MangledlIdentifierNamesGenerator.spec.ts

@@ -12,7 +12,7 @@ import { IdentifierNamesGenerator } from '../../../../src/enums/generators/ident
 import { InversifyContainerFacade } from '../../../../src/container/InversifyContainerFacade';
 
 describe('MangledIdentifierNamesGenerator', () => {
-    describe('generate (): string', () => {
+    describe('generate', () => {
         let identifierNamesGenerator: IIdentifierNamesGenerator,
             mangledIdentifierName: string;
 

+ 1 - 1
test/unit-tests/javascript-obfuscator/EspreeFacade.spec.ts

@@ -3,7 +3,7 @@ import { EspreeFacade } from '../../../src/EspreeFacade';
 
 
 describe('EspreeFacade', () => {
-    describe(`parse (input: string, config: espree.ParseOptions): ESTree.Program`, () => {
+    describe(`parse`, () => {
         describe(`\`Unexpected token\` error code preview`, () => {
             describe('Variant #1: 5 lines of code', () => {
                 const sourceCode: string = `` +

+ 1 - 1
test/unit-tests/javascript-obfuscator/JavaScriptObfuscator.spec.ts

@@ -11,7 +11,7 @@ import { NO_ADDITIONAL_NODES_PRESET } from '../../../src/options/presets/NoCusto
 import { InversifyContainerFacade } from '../../../src/container/InversifyContainerFacade';
 
 describe('JavaScriptObfuscator', () => {
-    describe(`obfuscate (sourceCode: string): IObfuscationResult`, () => {
+    describe(`obfuscate`, () => {
         describe(`source map`, () => {
             const code: string = 'var test = 1;';
             const sourceMapUrl: string = 'test.js.map';

+ 4 - 4
test/unit-tests/logger/Logger.spec.ts

@@ -17,7 +17,7 @@ import { Logger } from '../../../src/logger/Logger';
 import { LoggingMessage } from '../../../src/enums/logger/LoggingMessage';
 
 describe('Logger', () => {
-    describe('log (loggingLevelColor: Chalk, loggingPrefix: LoggingPrefix, loggingMessage: string, value?: string | number): void', () => {
+    describe('log', () => {
         const loggingMessage: string = '[javascript-obfuscator] foo';
         const expectedConsoleLogCallResult: boolean = true;
 
@@ -46,7 +46,7 @@ describe('Logger', () => {
         });
     });
 
-    describe('info (loggingMessage: LoggingMessage, value?: string | number): void', () => {
+    describe('info', () => {
         describe('`log` option is enabled', () => {
             const loggingMessage: string = '[javascript-obfuscator] Obfuscation started...';
             const expectedConsoleLogCallResult: boolean = true;
@@ -117,7 +117,7 @@ describe('Logger', () => {
         });
     });
 
-    describe('success (loggingMessage: LoggingMessage, value?: string | number): void', () => {
+    describe('success', () => {
         describe('`log` option is enabled', () => {
             const loggingMessage: string = '[javascript-obfuscator] Obfuscation started...';
             const expectedConsoleLogCallResult: boolean = true;
@@ -188,7 +188,7 @@ describe('Logger', () => {
         });
     });
 
-    describe('warn (loggingMessage: LoggingMessage, value?: string | number): void', () => {
+    describe('warn', () => {
         describe('`log` option is enabled', () => {
             const loggingMessage: string = '[javascript-obfuscator] Obfuscation started...';
             const expectedConsoleLogCallResult: boolean = true;

+ 1 - 1
test/unit-tests/node-transformers/preparing-transformers/ObfuscatingGuardsTransformer.spec.ts

@@ -16,7 +16,7 @@ import { NodeUtils } from '../../../../src/node/NodeUtils';
 import { NodeMetadata } from '../../../../src/node/NodeMetadata';
 
 describe('ObfuscatingGuardsTransformer', () => {
-    describe('transformNode (node: ESTree.Node, parentNode: ESTree.Node): ESTree.Node', () => {
+    describe('transformNode', () => {
         let inversifyContainerFacade: IInversifyContainerFacade,
             obfuscatingGuardsTransformer: INodeTransformer;
 

+ 22 - 22
test/unit-tests/node/node-appender/NodeAppender.spec.ts

@@ -41,7 +41,7 @@ const convertCodeToAst: (fixturePath: string) => ESTree.Program = (fixturePath)
 };
 
 describe('NodeAppender', () => {
-    describe('appendNode (blockScopeNode: TNodeWithBlockScope[], nodeBodyStatements: TStatement[]): void', () => {
+    describe('append', () => {
         let astTree: ESTree.Program,
             expectedAstTree: ESTree.Program,
             node: TStatement[];
@@ -51,10 +51,10 @@ describe('NodeAppender', () => {
             astTree = convertCodeToAst('/fixtures/append-node.js');
             expectedAstTree = convertCodeToAst('/fixtures/append-node-expected.js');
 
-            astTree = NodeUtils.parentize(astTree);
-            expectedAstTree = NodeUtils.parentize(expectedAstTree);
+            astTree = NodeUtils.parentizeAst(astTree);
+            expectedAstTree = NodeUtils.parentizeAst(expectedAstTree);
 
-            NodeAppender.appendNode(astTree, node);
+            NodeAppender.append(astTree, node);
         });
 
         it('should append given node to a `BlockStatement` node body', () => {
@@ -62,7 +62,7 @@ describe('NodeAppender', () => {
         });
     });
 
-    describe('appendNodeToOptimalBlockScope (blockScopeStackTraceData: IStackTraceData[], blockScopeNode: TNodeWithBlockScope, nodeBodyStatements: TStatement[], index: number = 0): void', () => {
+    describe('appendToOptimalBlockScope', () => {
         let stackTraceAnalyzer: IStackTraceAnalyzer,
             astTree: ESTree.Program,
             expectedAstTree: ESTree.Program,
@@ -87,7 +87,7 @@ describe('NodeAppender', () => {
                 expectedAstTree = convertCodeToAst('/fixtures/append-node-to-optimal-block-scope/variant-1-expected.js');
 
                 stackTraceData = stackTraceAnalyzer.analyze(astTree);
-                NodeAppender.appendNodeToOptimalBlockScope(stackTraceData, astTree, node);
+                NodeAppender.appendToOptimalBlockScope(stackTraceData, astTree, node);
             });
 
             it('should append node into first and deepest function call in nested function calls', () => {
@@ -101,7 +101,7 @@ describe('NodeAppender', () => {
                 expectedAstTree = convertCodeToAst('/fixtures/append-node-to-optimal-block-scope/variant-2-expected.js');
 
                 stackTraceData = stackTraceAnalyzer.analyze(astTree);
-                NodeAppender.appendNodeToOptimalBlockScope(stackTraceData, astTree, node);
+                NodeAppender.appendToOptimalBlockScope(stackTraceData, astTree, node);
 
             });
 
@@ -122,7 +122,7 @@ describe('NodeAppender', () => {
                     expectedAstTree = convertCodeToAst('/fixtures/append-node-to-optimal-block-scope/by-index-variant-1-expected.js');
 
                     stackTraceData = stackTraceAnalyzer.analyze(astTree);
-                    NodeAppender.appendNodeToOptimalBlockScope(stackTraceData, astTree, node, 2);
+                    NodeAppender.appendToOptimalBlockScope(stackTraceData, astTree, node, 2);
 
                 });
 
@@ -136,7 +136,7 @@ describe('NodeAppender', () => {
                     expectedAstTree = convertCodeToAst('/fixtures/append-node-to-optimal-block-scope/by-index-variant-2-expected.js');
 
                     stackTraceData = stackTraceAnalyzer.analyze(astTree);
-                    NodeAppender.appendNodeToOptimalBlockScope(stackTraceData, astTree, node, 1);
+                    NodeAppender.appendToOptimalBlockScope(stackTraceData, astTree, node, 1);
 
                 });
 
@@ -151,7 +151,7 @@ describe('NodeAppender', () => {
                     expectedAstTree = convertCodeToAst('/fixtures/append-node-to-optimal-block-scope/by-index-variant-3-expected.js');
 
                     stackTraceData = stackTraceAnalyzer.analyze(astTree);
-                    NodeAppender.appendNodeToOptimalBlockScope(
+                    NodeAppender.appendToOptimalBlockScope(
                         stackTraceData,
                         astTree,
                         node,
@@ -167,7 +167,7 @@ describe('NodeAppender', () => {
         });
     });
 
-    describe('insertNodeAfter (scopeNode: TNodeWithScope, scopeStatements: TStatement[], targetStatement: ESTree.Statement): void', () => {
+    describe('insertAfter', () => {
         let astTree: ESTree.Program,
             expectedAstTree: ESTree.Program,
             node: TStatement[],
@@ -179,10 +179,10 @@ describe('NodeAppender', () => {
             expectedAstTree = convertCodeToAst('/fixtures/insert-node-after-expected.js');
             targetStatement = <ESTree.Statement>astTree.body[1];
 
-            astTree = NodeUtils.parentize(astTree);
-            expectedAstTree = NodeUtils.parentize(expectedAstTree);
+            astTree = NodeUtils.parentizeAst(astTree);
+            expectedAstTree = NodeUtils.parentizeAst(expectedAstTree);
 
-            NodeAppender.insertNodeAfter(astTree, node, targetStatement);
+            NodeAppender.insertAfter(astTree, node, targetStatement);
         });
 
         it('should insert given node in `BlockStatement` node body after target statement', () => {
@@ -190,7 +190,7 @@ describe('NodeAppender', () => {
         });
     });
 
-    describe('insertNodeAtIndex (blockScopeNode: TNodeWithBlockScope[], nodeBodyStatements: TStatement[], index: number): void', () => {
+    describe('insertAtIndex', () => {
         let astTree: ESTree.Program,
             expectedAstTree: ESTree.Program,
             node: TStatement[];
@@ -200,10 +200,10 @@ describe('NodeAppender', () => {
             astTree = convertCodeToAst('/fixtures/insert-node-at-index.js');
             expectedAstTree = convertCodeToAst('/fixtures/insert-node-at-index-expected.js');
 
-            astTree = NodeUtils.parentize(astTree);
-            expectedAstTree = NodeUtils.parentize(expectedAstTree);
+            astTree = NodeUtils.parentizeAst(astTree);
+            expectedAstTree = NodeUtils.parentizeAst(expectedAstTree);
 
-            NodeAppender.insertNodeAtIndex(astTree, node, 2);
+            NodeAppender.insertAtIndex(astTree, node, 2);
         });
 
         it('should insert given node in `BlockStatement` node body at index', () => {
@@ -211,7 +211,7 @@ describe('NodeAppender', () => {
         });
     });
 
-    describe('prependNode (blockScopeNode: TNodeWithBlockScope[], nodeBodyStatements: TStatement[]): void', () => {
+    describe('prepend', () => {
         let astTree: ESTree.Program,
             expectedAstTree: ESTree.Program,
             node: TStatement[];
@@ -221,10 +221,10 @@ describe('NodeAppender', () => {
             astTree = convertCodeToAst('/fixtures/prepend-node.js');
             expectedAstTree = convertCodeToAst('/fixtures/prepend-node-expected.js');
 
-            astTree = NodeUtils.parentize(astTree);
-            expectedAstTree = NodeUtils.parentize(expectedAstTree);
+            astTree = NodeUtils.parentizeAst(astTree);
+            expectedAstTree = NodeUtils.parentizeAst(expectedAstTree);
 
-            NodeAppender.prependNode(astTree, node);
+            NodeAppender.prepend(astTree, node);
         });
 
         it('should prepend given node to a `BlockStatement` node body', () => {

+ 16 - 16
test/unit-tests/node/node-guards/NodeGuards.spec.ts

@@ -7,7 +7,7 @@ import { NodeFactory } from '../../../../src/node/NodeFactory';
 import { NodeUtils } from '../../../../src/node/NodeUtils';
 
 describe('NodeGuards', () => {
-    describe('isNodeHasBlockScope (node: ESTree.Node): node is TNodeWithBlockScope', () => {
+    describe('isNodeHasBlockScope', () => {
         describe('truthful checks', () => {
             describe('Variant #1: block statement of function declaration', () => {
                 const expectedResult: boolean = true;
@@ -21,7 +21,7 @@ describe('NodeGuards', () => {
                 let result: boolean;
 
                 before(() => {
-                    NodeUtils.parentize(parentNode);
+                    NodeUtils.parentizeAst(parentNode);
                     result = NodeGuards.isNodeHasBlockScope(node, parentNode);
                 });
 
@@ -41,7 +41,7 @@ describe('NodeGuards', () => {
                 let result: boolean;
 
                 before(() => {
-                    NodeUtils.parentize(parentNode);
+                    NodeUtils.parentizeAst(parentNode);
                     result = NodeGuards.isNodeHasBlockScope(node, parentNode);
                 });
 
@@ -79,7 +79,7 @@ describe('NodeGuards', () => {
                 let result: boolean;
 
                 before(() => {
-                    NodeUtils.parentize(parentNode);
+                    NodeUtils.parentizeAst(parentNode);
                     result = NodeGuards.isNodeHasBlockScope(node, parentNode);
                 });
 
@@ -107,7 +107,7 @@ describe('NodeGuards', () => {
                 let result: boolean;
 
                 before(() => {
-                    NodeUtils.parentize(parentNode);
+                    NodeUtils.parentizeAst(parentNode);
                     result = NodeGuards.isNodeHasBlockScope(node, parentNode);
                 });
 
@@ -127,7 +127,7 @@ describe('NodeGuards', () => {
                 let result: boolean;
 
                 before(() => {
-                    NodeUtils.parentize(parentNode);
+                    NodeUtils.parentizeAst(parentNode);
                     result = NodeGuards.isNodeHasBlockScope(node, parentNode);
                 });
 
@@ -138,7 +138,7 @@ describe('NodeGuards', () => {
         });
     });
 
-    describe('isNodeHasScope (node: ESTree.Node): node is TNodeWithScope', () => {
+    describe('isNodeHasScope', () => {
         describe('truthful checks', () => {
             describe('Variant #1: program node', () => {
                 const expectedResult: boolean = true;
@@ -258,7 +258,7 @@ describe('NodeGuards', () => {
         });
     });
 
-    describe('isReplaceableIdentifierNode (node: ESTree.Node, parentNode: ESTree.Node): node is ESTree.Identifier', () => {
+    describe('isReplaceableIdentifierNode', () => {
         describe('truthful checks', () => {
             describe('Variant #1: parent node is function declaration node', () => {
                 const expectedResult: boolean = true;
@@ -272,7 +272,7 @@ describe('NodeGuards', () => {
                 let result: boolean;
 
                 before(() => {
-                    NodeUtils.parentize(parentNode);
+                    NodeUtils.parentizeAst(parentNode);
                     result = NodeGuards.isReplaceableIdentifierNode(identifier, parentNode);
                 });
 
@@ -293,7 +293,7 @@ describe('NodeGuards', () => {
                 let result: boolean;
 
                 before(() => {
-                    NodeUtils.parentize(parentNode);
+                    NodeUtils.parentizeAst(parentNode);
                     result = NodeGuards.isReplaceableIdentifierNode(identifier, parentNode);
                 });
 
@@ -314,7 +314,7 @@ describe('NodeGuards', () => {
                 let result: boolean;
 
                 before(() => {
-                    NodeUtils.parentize(parentNode);
+                    NodeUtils.parentizeAst(parentNode);
                     result = NodeGuards.isReplaceableIdentifierNode(identifier, parentNode);
                 });
 
@@ -336,7 +336,7 @@ describe('NodeGuards', () => {
                 let result: boolean;
 
                 before(() => {
-                    NodeUtils.parentize(parentNode);
+                    NodeUtils.parentizeAst(parentNode);
                     result = NodeGuards.isReplaceableIdentifierNode(identifier, parentNode);
                 });
 
@@ -360,7 +360,7 @@ describe('NodeGuards', () => {
                 let result: boolean;
 
                 before(() => {
-                    NodeUtils.parentize(parentNode);
+                    NodeUtils.parentizeAst(parentNode);
                     result = NodeGuards.isReplaceableIdentifierNode(literal, parentNode);
                 });
 
@@ -381,7 +381,7 @@ describe('NodeGuards', () => {
                 let result: boolean;
 
                 before(() => {
-                    NodeUtils.parentize(parentNode);
+                    NodeUtils.parentizeAst(parentNode);
                     result = NodeGuards.isReplaceableIdentifierNode(identifier, parentNode);
                 });
 
@@ -402,7 +402,7 @@ describe('NodeGuards', () => {
                 let result: boolean;
 
                 before(() => {
-                    NodeUtils.parentize(parentNode);
+                    NodeUtils.parentizeAst(parentNode);
                     result = NodeGuards.isReplaceableIdentifierNode(identifier, parentNode);
                 });
 
@@ -424,7 +424,7 @@ describe('NodeGuards', () => {
                 let result: boolean;
 
                 before(() => {
-                    NodeUtils.parentize(parentNode);
+                    NodeUtils.parentizeAst(parentNode);
                     result = NodeGuards.isReplaceableIdentifierNode(identifier, parentNode);
                 });
 

+ 3 - 3
test/unit-tests/node/node-metadata/NodeMetadata.spec.ts

@@ -47,7 +47,7 @@ describe('NodeMetadata', () => {
         });
     });
 
-    describe('isIgnoredNode (node: ESTree.Node): boolean', () => {
+    describe('isIgnoredNode', () => {
         const expectedValue: boolean = true;
 
         let node: ESTree.Identifier,
@@ -65,7 +65,7 @@ describe('NodeMetadata', () => {
         });
     });
 
-    describe('isRenamedIdentifier (identifierNode: ESTree.Identifier): boolean', () => {
+    describe('isRenamedIdentifier', () => {
         const expectedValue: boolean = true;
 
         let node: ESTree.Identifier,
@@ -83,7 +83,7 @@ describe('NodeMetadata', () => {
         });
     });
 
-    describe('isReplacedLiteral (literalNode: ESTree.Literal): boolean', () => {
+    describe('isReplacedLiteral', () => {
         const expectedValue: boolean = true;
 
         let node: ESTree.Literal,

+ 28 - 28
test/unit-tests/node/node-utils/NodeUtils.spec.ts

@@ -10,7 +10,7 @@ import { NodeFactory } from '../../../../src/node/NodeFactory';
 import { NodeUtils } from '../../../../src/node/NodeUtils';
 
 describe('NodeUtils', () => {
-    describe('addXVerbatimPropertyToLiterals (node: ESTree.Node): void', () => {
+    describe('addXVerbatimPropertyTo', () => {
         let literalNode: ESTree.Literal,
             expectedLiteralNode: ESTree.Literal;
 
@@ -20,7 +20,7 @@ describe('NodeUtils', () => {
 
             expectedLiteralNode = NodeFactory.literalNode('value');
 
-            NodeUtils.addXVerbatimPropertyToLiteralNode(literalNode);
+            NodeUtils.addXVerbatimPropertyTo(literalNode);
         });
 
         it('should add `x-verbatim-property` to `Literal` node', () => {
@@ -28,7 +28,7 @@ describe('NodeUtils', () => {
         });
     });
 
-    describe('clone <T extends ESTree.Node> (astTree: T): T', () => {
+    describe('clone', () => {
         describe('Variant #1: simple AST-tree', () => {
             let programNode: ESTree.Program,
                 expectedProgramNode: ESTree.Program;
@@ -67,7 +67,7 @@ describe('NodeUtils', () => {
                         ifStatementNode1
                     ])
                 );
-                expectedProgramNode = NodeUtils.parentize(
+                expectedProgramNode = NodeUtils.parentizeAst(
                     NodeFactory.programNode([
                         ifStatementNode2
                     ])
@@ -111,7 +111,7 @@ describe('NodeUtils', () => {
                         expressionStatementNode
                     ])
                 );
-                expectedProgramNode = NodeUtils.parentize(
+                expectedProgramNode = NodeUtils.parentizeAst(
                     NodeFactory.programNode([
                         expectedExpressionStatementNode
                     ])
@@ -124,7 +124,7 @@ describe('NodeUtils', () => {
         });
     });
 
-    describe('convertCodeToStructure (code: string): ESTree.Statement[]', () => {
+    describe('convertCodeToStructure', () => {
         let structure: TStatement[],
             expectedStructure: TStatement[];
 
@@ -158,7 +158,7 @@ describe('NodeUtils', () => {
         });
     });
 
-    describe('convertStructureToCode (structure: ESTree.Node[]): string', () => {
+    describe('convertStructureToCode', () => {
         let structure: ESTree.Node[],
             expectedCode: string;
 
@@ -181,7 +181,7 @@ describe('NodeUtils', () => {
         });
     });
 
-    describe('getBlockScopesOfNode (node: ESTree.Node, blockScopes: TNodeWithBlockScope[] = []): TNodeWithBlockScope[]', () => {
+    describe('getBlockScopesOfNode', () => {
         let functionDeclarationBlockStatementNode: ESTree.BlockStatement,
             ifStatementBlockStatementNode1: ESTree.BlockStatement,
             ifStatementBlockStatementNode2: ESTree.BlockStatement,
@@ -296,7 +296,7 @@ describe('NodeUtils', () => {
         });
     });
 
-    describe('getNextSiblingStatementNode (node: ESTree.Statement): TStatement | null', () => {
+    describe('getNextSiblingStatement', () => {
         describe('Variant #1: block statement node as scope node', () => {
                 let statementNode1: ESTree.Statement,
                 statementNode2: ESTree.Statement,
@@ -325,15 +325,15 @@ describe('NodeUtils', () => {
             });
 
             it('should return next sibling statement node', () => {
-                assert.deepEqual(NodeUtils.getNextSiblingStatementNode(statementNode1), statementNode2);
+                assert.deepEqual(NodeUtils.getNextSiblingStatement(statementNode1), statementNode2);
             });
 
             it('should return next sibling statement node', () => {
-                assert.deepEqual(NodeUtils.getNextSiblingStatementNode(statementNode2), statementNode3);
+                assert.deepEqual(NodeUtils.getNextSiblingStatement(statementNode2), statementNode3);
             });
 
             it('should return `null` if given statement node is last node in the scope', () => {
-                assert.deepEqual(NodeUtils.getNextSiblingStatementNode(statementNode3), null);
+                assert.deepEqual(NodeUtils.getNextSiblingStatement(statementNode3), null);
             });
         });
 
@@ -368,20 +368,20 @@ describe('NodeUtils', () => {
             });
 
             it('should return next sibling statement node', () => {
-                assert.deepEqual(NodeUtils.getNextSiblingStatementNode(statementNode1), statementNode2);
+                assert.deepEqual(NodeUtils.getNextSiblingStatement(statementNode1), statementNode2);
             });
 
             it('should return next sibling statement node', () => {
-                assert.deepEqual(NodeUtils.getNextSiblingStatementNode(statementNode2), statementNode3);
+                assert.deepEqual(NodeUtils.getNextSiblingStatement(statementNode2), statementNode3);
             });
 
             it('should return `null` if given statement node is last node in the scope', () => {
-                assert.deepEqual(NodeUtils.getNextSiblingStatementNode(statementNode3), null);
+                assert.deepEqual(NodeUtils.getNextSiblingStatement(statementNode3), null);
             });
         });
     });
 
-    describe('getPreviousSiblingStatementNode (node: ESTree.Statement): TStatement | null', () => {
+    describe('getPreviousSiblingStatement', () => {
         describe('Variant #1: block statement node as scope node', () => {
             let statementNode1: ESTree.Statement,
                 statementNode2: ESTree.Statement,
@@ -410,15 +410,15 @@ describe('NodeUtils', () => {
             });
 
             it('should return next sibling statement node', () => {
-                assert.deepEqual(NodeUtils.getPreviousSiblingStatementNode(statementNode1), null);
+                assert.deepEqual(NodeUtils.getPreviousSiblingStatement(statementNode1), null);
             });
 
             it('should return next sibling statement node', () => {
-                assert.deepEqual(NodeUtils.getPreviousSiblingStatementNode(statementNode2), statementNode1);
+                assert.deepEqual(NodeUtils.getPreviousSiblingStatement(statementNode2), statementNode1);
             });
 
             it('should return `null` if given statement node is last node in the scope', () => {
-                assert.deepEqual(NodeUtils.getPreviousSiblingStatementNode(statementNode3), statementNode2);
+                assert.deepEqual(NodeUtils.getPreviousSiblingStatement(statementNode3), statementNode2);
             });
         });
 
@@ -453,20 +453,20 @@ describe('NodeUtils', () => {
             });
 
             it('should return next sibling statement node', () => {
-                assert.deepEqual(NodeUtils.getPreviousSiblingStatementNode(statementNode1), null);
+                assert.deepEqual(NodeUtils.getPreviousSiblingStatement(statementNode1), null);
             });
 
             it('should return next sibling statement node', () => {
-                assert.deepEqual(NodeUtils.getPreviousSiblingStatementNode(statementNode2), statementNode1);
+                assert.deepEqual(NodeUtils.getPreviousSiblingStatement(statementNode2), statementNode1);
             });
 
             it('should return `null` if given statement node is last node in the scope', () => {
-                assert.deepEqual(NodeUtils.getPreviousSiblingStatementNode(statementNode3), statementNode2);
+                assert.deepEqual(NodeUtils.getPreviousSiblingStatement(statementNode3), statementNode2);
             });
         });
     });
 
-    describe('getScopeOfNode (node: ESTree.Node): TNodeWithScope | null', () => {
+    describe('getScopeOfNode', () => {
         let functionDeclarationBlockStatementNode: ESTree.BlockStatement,
             ifStatementBlockStatementNode1: ESTree.BlockStatement,
             ifStatementBlockStatementNode2: ESTree.BlockStatement,
@@ -607,7 +607,7 @@ describe('NodeUtils', () => {
         });
     });
 
-    describe('getUnaryExpressionArgumentNode (unaryExpressionNode: ESTree.UnaryExpression): ESTree.Node', () => {
+    describe('getUnaryExpressionArgumentNode', () => {
         let expectedNode: ESTree.Literal,
             unaryExpressionArgumentNode: ESTree.Node;
 
@@ -635,7 +635,7 @@ describe('NodeUtils', () => {
         });
     });
 
-    describe('parentize <T extends ESTree.Node> (astTree: T): T', () => {
+    describe('parentizeAst', () => {
         let ifStatementNode: ESTree.IfStatement,
             ifStatementBlockStatementNode: ESTree.BlockStatement,
             expressionStatementNode1: ESTree.ExpressionStatement,
@@ -663,7 +663,7 @@ describe('NodeUtils', () => {
                     ifStatementNode
                 ]);
 
-                programNode = NodeUtils.parentize(programNode);
+                programNode = NodeUtils.parentizeAst(programNode);
             });
 
             it('should parentize `program` node with `ProgramNode` as root node', () => {
@@ -689,7 +689,7 @@ describe('NodeUtils', () => {
 
         describe('Variant #2: parentize AST-tree', () => {
             beforeEach(() => {
-                ifStatementNode = NodeUtils.parentize(ifStatementNode);
+                ifStatementNode = NodeUtils.parentizeAst(ifStatementNode);
             });
 
             it('should parentize `ifStatement` node', () => {
@@ -710,7 +710,7 @@ describe('NodeUtils', () => {
         });
     });
 
-    describe('parentizeNode <T extends ESTree.Node = ESTree.Program> (node: T, parentNode: ESTree.Node): T', () => {
+    describe('parentizeNode', () => {
         describe('Variant #1: node with parent node', () => {
             const identifier: ESTree.Identifier = NodeFactory.identifierNode('foo');
             const breakStatement: ESTree.BreakStatement = NodeFactory.breakStatement(identifier);

+ 1 - 1
test/unit-tests/obfuscation-result/ObfuscationResult.spec.ts

@@ -5,7 +5,7 @@ import { IObfuscationResult } from '../../../src/interfaces/IObfuscationResult';
 import { ObfuscationResult } from '../../../src/ObfuscationResult';
 
 describe('ObfuscationResult', () => {
-    describe('constructor (obfuscatedCode: string, sourceMap: string)', () => {
+    describe('constructor', () => {
         let obfuscatedCode: string = 'obfuscatedCode',
             obfuscationResult: IObfuscationResult,
             sourceMap: string = 'sourceMap';

+ 1 - 1
test/unit-tests/options/ValidationErrorsFormatter.spec.ts

@@ -5,7 +5,7 @@ import { ValidationError } from 'class-validator';
 import { ValidationErrorsFormatter } from '../../../src/options/ValidationErrorsFormatter';
 
 describe('ValidationErrorsFormatter', () => {
-    describe('format (validationErrors: ValidationError[]): string', () => {
+    describe('format', () => {
         describe('Variant #1: one constraint group with one constraint', () => {
             const constraintGroupRegExp: RegExp = /`foo` *errors:/;
             const constraintRegExp: RegExp = /(?: *-)+ *constraint *text/;

+ 1 - 1
test/unit-tests/source-map/SourceMapCorrector.spec.ts

@@ -43,7 +43,7 @@ function getCorrectedObfuscationResult (
 }
 
 describe('SourceMapCorrector', () => {
-    describe('correct (): IObfuscationResult', () => {
+    describe('correct', () => {
         const expectedObfuscatedCode: string = 'var test = 1;';
         const sourceMap: string = 'test';
 

+ 7 - 7
test/unit-tests/storages/ArrayStorage.spec.ts

@@ -43,7 +43,7 @@ describe('ArrayStorage', () => {
 
     let storage: IArrayStorage <any>;
 
-    describe('initialize (...args: any[]): void', () => {
+    describe('initialize', () => {
         const expectedError: ErrorConstructor = Error;
 
         let testFunc: () => void;
@@ -58,7 +58,7 @@ describe('ArrayStorage', () => {
         });
     });
 
-    describe('getStorage (): T[]', () => {
+    describe('getStorage', () => {
         const expectedInstanceOf: ArrayConstructor = Array;
 
         let arrayStorage: string[];
@@ -74,7 +74,7 @@ describe('ArrayStorage', () => {
         });
     });
 
-    describe('get (key: number): T', () => {
+    describe('get', () => {
         describe('Variant #1: value exist', () => {
             const expectedValue: string = storageValue;
 
@@ -109,7 +109,7 @@ describe('ArrayStorage', () => {
         });
     });
 
-    describe('getLength (): number', () => {
+    describe('getLength', () => {
         const expectedStorageLength: number = 1;
 
         let storageLength: number;
@@ -126,7 +126,7 @@ describe('ArrayStorage', () => {
         });
     });
 
-    describe('getKeyOf (value: T): number | null', () => {
+    describe('getKeyOf', () => {
         let key: string | number | null;
 
         describe('Variant #1', () => {
@@ -178,7 +178,7 @@ describe('ArrayStorage', () => {
         });
     });
 
-    describe('set (key: number, value: T): void', () => {
+    describe('set', () => {
         let value: string;
 
         before(() => {
@@ -193,7 +193,7 @@ describe('ArrayStorage', () => {
         });
     });
 
-    describe('mergeWith (storage: this, mergeId: boolean = false): void', () => {
+    describe('mergeWith', () => {
         const secondStorageKey: number = 1;
         const secondStorageValue: string = 'bar';
 

+ 8 - 8
test/unit-tests/storages/MapStorage.spec.ts

@@ -42,7 +42,7 @@ describe('MapStorage', () => {
 
     let storage: IMapStorage <string, any>;
 
-    describe('initialize (...args: any[]): void', () => {
+    describe('initialize', () => {
         const expectedError: ErrorConstructor = Error;
 
         let testFunc: () => void;
@@ -57,7 +57,7 @@ describe('MapStorage', () => {
         });
     });
 
-    describe('getStorage (): Map <K, V>', () => {
+    describe('getStorage', () => {
         const expectedInstanceOf: MapConstructor = Map;
 
         let mapStorage: Map <string, string>;
@@ -73,7 +73,7 @@ describe('MapStorage', () => {
         });
     });
 
-    describe('get (key: K): V', () => {
+    describe('get', () => {
         describe('Variant #1: value exist', () => {
             const expectedValue: string = storageValue;
 
@@ -108,7 +108,7 @@ describe('MapStorage', () => {
         });
     });
 
-    describe('getLength (): number', () => {
+    describe('getLength', () => {
         const expectedStorageLength: number = 1;
 
         let storageLength: number;
@@ -125,7 +125,7 @@ describe('MapStorage', () => {
         });
     });
 
-    describe('getKeyOf (value: V): K | null', () => {
+    describe('getKeyOf', () => {
         let key: string | number | null;
 
         describe('Variant #1', () => {
@@ -177,7 +177,7 @@ describe('MapStorage', () => {
         });
     });
 
-    describe('has (key: K): boolean', () => {
+    describe('has', () => {
         describe('Variant #1: item is presenting in storage', () => {
             const expectedItemExistence: boolean = true;
 
@@ -212,7 +212,7 @@ describe('MapStorage', () => {
         });
     });
 
-    describe('set (key: K, value: V): void', () => {
+    describe('set', () => {
         let value: string;
 
         before(() => {
@@ -227,7 +227,7 @@ describe('MapStorage', () => {
         });
     });
 
-    describe('mergeWith (storage: this, mergeId: boolean = false): void', () => {
+    describe('mergeWith', () => {
         const secondStorageKey: string = 'baz';
         const secondStorageValue: string = 'quux';
 

+ 9 - 9
test/unit-tests/utils/ArrayUtils.spec.ts

@@ -7,7 +7,7 @@ import { IInversifyContainerFacade } from '../../../src/interfaces/container/IIn
 
 import { InversifyContainerFacade } from '../../../src/container/InversifyContainerFacade';
 
-describe('Utils', () => {
+describe('ArrayUtils', () => {
     let arrayUtils: IArrayUtils;
 
     before(() => {
@@ -17,7 +17,7 @@ describe('Utils', () => {
         arrayUtils = inversifyContainerFacade.get<IArrayUtils>(ServiceIdentifiers.IArrayUtils);
     });
 
-    describe('arrayRange (length: number): number[]', () => {
+    describe('createWithRange', () => {
         describe('range length more than 0', () => {
             const rangeLength: number = 5;
             const expectedArray: number[] = [0, 1, 2, 3, 4];
@@ -25,7 +25,7 @@ describe('Utils', () => {
             let array: number[];
 
             before(() => {
-                array = arrayUtils.arrayRange(rangeLength);
+                array = arrayUtils.createWithRange(rangeLength);
             });
 
             it('should return array with range of numbers', () => {
@@ -40,7 +40,7 @@ describe('Utils', () => {
             let array: number[];
 
             before(() => {
-                array = arrayUtils.arrayRange(rangeLength);
+                array = arrayUtils.createWithRange(rangeLength);
             });
 
             it('should return empty array', () => {
@@ -55,7 +55,7 @@ describe('Utils', () => {
             let array: number[];
 
             before(() => {
-                array = arrayUtils.arrayRange(rangeLength);
+                array = arrayUtils.createWithRange(rangeLength);
             });
 
             it('should return empty array', () => {
@@ -64,7 +64,7 @@ describe('Utils', () => {
         });
     });
 
-    describe('arrayRotate <T> (array: T[], times: number): T[]', () => {
+    describe('rotate', () => {
         let array: number[],
             rotatedArray: number[];
 
@@ -77,7 +77,7 @@ describe('Utils', () => {
             const expectedArray: number[] = [5, 6, 1, 2, 3, 4];
 
             beforeEach(() => {
-                rotatedArray = arrayUtils.arrayRotate(array, rotateValue);
+                rotatedArray = arrayUtils.rotate(array, rotateValue);
             });
 
             it('should rotate (shift) array by a given value', () => {
@@ -90,7 +90,7 @@ describe('Utils', () => {
             const expectedArray: number[] = [1, 2, 3, 4, 5, 6];
 
             beforeEach(() => {
-                rotatedArray = arrayUtils.arrayRotate(array, rotateValue);
+                rotatedArray = arrayUtils.rotate(array, rotateValue);
             });
 
             it('shouldn\'t rotate array', () => {
@@ -106,7 +106,7 @@ describe('Utils', () => {
             let testFunc: () => void;
 
             beforeEach(() => {
-                testFunc = () => arrayUtils.arrayRotate(emptyArray, rotateValue);
+                testFunc = () => arrayUtils.rotate(emptyArray, rotateValue);
             });
 
             it('should throw exception if array is empty', () => {

+ 3 - 3
test/unit-tests/utils/CryptUtils.spec.ts

@@ -17,7 +17,7 @@ describe('CryptUtils', () => {
         cryptUtils = inversifyContainerFacade.get<ICryptUtils>(ServiceIdentifiers.ICryptUtils);
     });
 
-    describe('btoa (string: string): string', () => {
+    describe('btoa', () => {
         const expectedString: string = 'c3RyaW5n';
 
         let string: string;
@@ -31,7 +31,7 @@ describe('CryptUtils', () => {
         });
     });
 
-    describe('hideString (str: string, length: number): [string, string]', () => {
+    describe('hideString', () => {
         const originalString: string = 'example.com';
         const hiddenStringLength: number = 30;
 
@@ -71,7 +71,7 @@ describe('CryptUtils', () => {
         });
     });
 
-    describe('rc4 (string: string, key: string): string', () => {
+    describe('rc4', () => {
         const string: string = 'test';
         const key: string = 'key';
 

+ 1 - 1
test/unit-tests/utils/EscapeSequenceEncoder.spec.ts

@@ -8,7 +8,7 @@ import { IEscapeSequenceEncoder } from '../../../src/interfaces/utils/IEscapeSeq
 
 
 describe('EscapeSequenceEncoder', () => {
-    describe('encode (string: string, encodeAllSymbols: boolean = false): string', () => {
+    describe('encode', () => {
         let escapeSequenceEncoder: IEscapeSequenceEncoder;
 
         before(() => {

+ 99 - 0
test/unit-tests/utils/NumberUtils.spec.ts

@@ -0,0 +1,99 @@
+import { assert } from 'chai';
+
+import { NumberUtils } from '../../../src/utils/NumberUtils';
+
+describe('NumberUtils', () => {
+    describe('toHex', () => {
+        describe('Variant #1: number `0`', () => {
+            const number: number = 0;
+            const expectedHexString = '0';
+
+            let hexString: string;
+
+            before(() => {
+                hexString = NumberUtils.toHex(number);
+            });
+
+            it('should create a string with hexadecimal value from a given decimal number', () => {
+                assert.equal(hexString, expectedHexString);
+            });
+        });
+
+        describe('Variant #2: number `10`', () => {
+            const number: number = 10;
+            const expectedHexString = 'a';
+
+            let hexString: string;
+
+            before(() => {
+                hexString = NumberUtils.toHex(number);
+            });
+
+            it('should create a string with hexadecimal value from a given decimal number', () => {
+                assert.equal(hexString, expectedHexString);
+            });
+        });
+
+        describe('Variant #3: number `17`', () => {
+            const number: number = 17;
+            const expectedHexString = '11';
+
+            let hexString: string;
+
+            before(() => {
+                hexString = NumberUtils.toHex(number);
+            });
+
+            it('should create a string with hexadecimal value from a given decimal number', () => {
+                assert.equal(hexString, expectedHexString);
+            });
+        });
+
+        describe('Variant #4: number `536870912`', () => {
+            const number: number = 536870912;
+            const expectedHexString = '20000000';
+
+            let hexString: string;
+
+            before(() => {
+                hexString = NumberUtils.toHex(number);
+            });
+
+            it('should create a string with hexadecimal value from a given decimal number', () => {
+                assert.equal(hexString, expectedHexString);
+            });
+        });
+    });
+
+    describe('isCeil', () => {
+        describe('given number is a ceil', () => {
+            const number: number = 4;
+            const expectedResult: boolean = true;
+
+            let result: boolean;
+
+            before(() => {
+                result = NumberUtils.isCeil(number);
+            });
+
+            it('should return true', () => {
+                assert.equal(result, expectedResult);
+            });
+        });
+
+        describe('given number is a float', () => {
+            const number: number = 4.5;
+            const expectedResult: boolean = false;
+
+            let result: boolean;
+
+            before(() => {
+                result = NumberUtils.isCeil(number);
+            });
+
+            it('should return false', () => {
+                assert.equal(result, expectedResult);
+            });
+        });
+    });
+});

+ 6 - 165
test/unit-tests/utils/Utils.spec.ts

@@ -1,73 +1,9 @@
 import { assert } from 'chai';
 
-import { JSFuck } from '../../../src/enums/JSFuck';
-
 import { Utils } from '../../../src/utils/Utils';
 
 describe('Utils', () => {
-    describe('decToHex (dec: number): string', () => {
-        describe('Variant #1: number `0`', () => {
-            const number: number = 0;
-            const expectedHexString = '0';
-
-            let hexString: string;
-
-            before(() => {
-                hexString = Utils.decToHex(number);
-            });
-
-            it('should create a string with hexadecimal value from a given decimal number', () => {
-                assert.equal(hexString, expectedHexString);
-            });
-        });
-
-        describe('Variant #2: number `10`', () => {
-            const number: number = 10;
-            const expectedHexString = 'a';
-
-            let hexString: string;
-
-            before(() => {
-                hexString = Utils.decToHex(number);
-            });
-
-            it('should create a string with hexadecimal value from a given decimal number', () => {
-                assert.equal(hexString, expectedHexString);
-            });
-        });
-
-        describe('Variant #3: number `17`', () => {
-            const number: number = 17;
-            const expectedHexString = '11';
-
-            let hexString: string;
-
-            before(() => {
-                hexString = Utils.decToHex(number);
-            });
-
-            it('should create a string with hexadecimal value from a given decimal number', () => {
-                assert.equal(hexString, expectedHexString);
-            });
-        });
-
-        describe('Variant #4: number `536870912`', () => {
-            const number: number = 536870912;
-            const expectedHexString = '20000000';
-
-            let hexString: string;
-
-            before(() => {
-                hexString = Utils.decToHex(number);
-            });
-
-            it('should create a string with hexadecimal value from a given decimal number', () => {
-                assert.equal(hexString, expectedHexString);
-            });
-        });
-    });
-
-    describe('extractDomainFromUrl (url: string): string', () => {
+    describe('extractDomainFrom', () => {
         describe('Variant #1: simple url', () => {
             const url: string = 'http://google.ru';
             const expectedDomain: string = 'google.ru';
@@ -75,7 +11,7 @@ describe('Utils', () => {
             let domain: string;
 
             before(() => {
-                domain = Utils.extractDomainFromUrl(url);
+                domain = Utils.extractDomainFrom(url);
             });
 
             it('should extract domain from the given URL', () => {
@@ -90,7 +26,7 @@ describe('Utils', () => {
             let domain: string;
 
             before(() => {
-                domain = Utils.extractDomainFromUrl(url);
+                domain = Utils.extractDomainFrom(url);
             });
 
             it('should extract domain from the given URL', () => {
@@ -105,7 +41,7 @@ describe('Utils', () => {
             let domain: string;
 
             before(() => {
-                domain = Utils.extractDomainFromUrl(url);
+                domain = Utils.extractDomainFrom(url);
             });
 
             it('should extract domain from the given URL', () => {
@@ -120,7 +56,7 @@ describe('Utils', () => {
             let domain: string;
 
             before(() => {
-                domain = Utils.extractDomainFromUrl(url);
+                domain = Utils.extractDomainFrom(url);
             });
 
             it('should extract domain from the given URL', () => {
@@ -135,7 +71,7 @@ describe('Utils', () => {
             let domain: string;
 
             before(() => {
-                domain = Utils.extractDomainFromUrl(url);
+                domain = Utils.extractDomainFrom(url);
             });
 
             it('should extract domain from the given URL', () => {
@@ -143,99 +79,4 @@ describe('Utils', () => {
             });
         });
     });
-
-    describe('isCeilNumber (number: number): boolean', () => {
-        describe('given number is a ceil', () => {
-            const number: number = 4;
-            const expectedResult: boolean = true;
-
-            let result: boolean;
-
-            before(() => {
-                result = Utils.isCeilNumber(number);
-            });
-
-            it('should return true', () => {
-                assert.equal(result, expectedResult);
-            });
-        });
-
-        describe('given number is a float', () => {
-            const number: number = 4.5;
-            const expectedResult: boolean = false;
-
-            let result: boolean;
-
-            before(() => {
-                result = Utils.isCeilNumber(number);
-            });
-
-            it('should return false', () => {
-                assert.equal(result, expectedResult);
-            });
-        });
-    });
-
-    describe('stringRotate (string: string, times: number): string', () => {
-        const string: string = 'abcdefg';
-
-        let rotatedString: string;
-
-        describe('value is not 0', () => {
-            const rotateValue: number = 2;
-            const expectedString: string = 'fgabcde';
-
-            before(() => {
-                rotatedString = Utils.stringRotate(string, rotateValue);
-            });
-
-            it('should rotate string by a given value', () => {
-                assert.deepEqual(rotatedString, expectedString);
-            });
-        });
-
-        describe('value equals or less 0', () => {
-            const rotateValue: number = 0;
-            const expectedString: string = 'abcdefg';
-
-            before(() => {
-                rotatedString = Utils.stringRotate(string, rotateValue);
-            });
-
-            it('shouldn\'t rotate string', () => {
-                assert.deepEqual(rotatedString, expectedString);
-            });
-        });
-
-        describe('empty array', () => {
-            const emptyString: string = '';
-            const rotateValue: number = 5;
-            const expectedError: ReferenceErrorConstructor = ReferenceError;
-
-            let testFunc: () => void ;
-
-            before(() => {
-                testFunc = () => Utils.stringRotate(emptyString, rotateValue);
-            });
-
-            it('should throw exception if string is empty', () => {
-                assert.throws(testFunc, expectedError);
-            });
-        });
-    });
-
-    describe('stringToJSFuck (string: string): string', () => {
-        const string: string = 'string';
-        const expectedString: string = `${JSFuck.s} + ${JSFuck.t} + ${JSFuck.r} + ${JSFuck.i} + ${JSFuck.n} + ${JSFuck.g}`;
-
-        let actualString: string;
-
-        before(() => {
-            actualString = Utils.stringToJSFuck(string);
-        });
-
-        it('should create a JSFuck encoded string from a given string', () => {
-            assert.equal(actualString, expectedString);
-        });
-    });
 });

Bu fark içinde çok fazla dosya değişikliği olduğu için bazı dosyalar gösterilmiyor