Przeglądaj źródła

Sync with 0.17.2 branch

sanex3339 6 lat temu
rodzic
commit
348cd78443
100 zmienionych plików z 1570 dodań i 1664 usunięć
  1. 4 0
      CHANGELOG.md
  2. 0 0
      dist/index.browser.js
  3. 0 0
      dist/index.cli.js
  4. 0 0
      dist/index.js
  5. 16 16
      package.json
  6. 17 19
      src/JavaScriptObfuscator.ts
  7. 6 6
      src/JavaScriptObfuscatorFacade.ts
  8. 0 50
      src/ObfuscationResult.ts
  9. 0 22
      src/SourceCode.ts
  10. 2 2
      src/analyzers/stack-trace-analyzer/StackTraceAnalyzer.ts
  11. 2 2
      src/analyzers/stack-trace-analyzer/callee-data-extractors/FunctionDeclarationCalleeDataExtractor.ts
  12. 2 2
      src/analyzers/stack-trace-analyzer/callee-data-extractors/FunctionExpressionCalleeDataExtractor.ts
  13. 2 2
      src/analyzers/stack-trace-analyzer/callee-data-extractors/ObjectExpressionCalleeDataExtractor.ts
  14. 5 5
      src/cli/JavaScriptObfuscatorCLI.ts
  15. 16 23
      src/container/InversifyContainerFacade.ts
  16. 2 2
      src/container/ServiceIdentifiers.ts
  17. 2 2
      src/custom-nodes/AbstractCustomNode.ts
  18. 3 3
      src/custom-nodes/AbstractCustomNodeGroup.ts
  19. 8 12
      src/custom-nodes/console-output-nodes/group/ConsoleOutputCustomNodeGroup.ts
  20. 14 15
      src/custom-nodes/debug-protection-nodes/group/DebugProtectionCustomNodeGroup.ts
  21. 8 12
      src/custom-nodes/domain-lock-nodes/group/DomainLockCustomNodeGroup.ts
  22. 8 12
      src/custom-nodes/self-defending-nodes/group/SelfDefendingCustomNodeGroup.ts
  23. 6 6
      src/custom-nodes/string-array-nodes/group/StringArrayCustomNodeGroup.ts
  24. 2 2
      src/interfaces/IInitializable.d.ts
  25. 3 3
      src/interfaces/IJavaScriptObfsucator.d.ts
  26. 4 3
      src/interfaces/container/IInversifyContainerFacade.d.ts
  27. 1 1
      src/interfaces/custom-nodes/ICustomNode.d.ts
  28. 3 3
      src/interfaces/custom-nodes/ICustomNodeGroup.d.ts
  29. 5 5
      src/interfaces/node-transformers/obfuscating-transformers/obfuscating-replacers/IIdentifierObfuscatingReplacer.d.ts
  30. 3 3
      src/interfaces/node-transformers/obfuscating-transformers/obfuscating-replacers/IObfuscatingReplacer.d.ts
  31. 2 2
      src/interfaces/source-code/IObfuscatedCode.d.ts
  32. 5 0
      src/interfaces/source-code/ISourceCode.d.ts
  33. 0 10
      src/interfaces/source-map/ISourceMapCorrector.d.ts
  34. 0 5
      src/interfaces/storages/IArrayStorage.d.ts
  35. 0 5
      src/interfaces/storages/IMapStorage.d.ts
  36. 0 7
      src/interfaces/utils/IRandomGenerator.d.ts
  37. 15 11
      src/node-transformers/control-flow-transformers/FunctionControlFlowTransformer.ts
  38. 18 15
      src/node-transformers/converting-transformers/properties-extractors/AbstractPropertiesExtractor.ts
  39. 19 12
      src/node-transformers/dead-code-injection-transformers/DeadCodeInjectionTransformer.ts
  40. 15 11
      src/node-transformers/obfuscating-transformers/CatchClauseTransformer.ts
  41. 26 21
      src/node-transformers/obfuscating-transformers/ClassDeclarationTransformer.ts
  42. 26 21
      src/node-transformers/obfuscating-transformers/FunctionDeclarationTransformer.ts
  43. 50 46
      src/node-transformers/obfuscating-transformers/FunctionTransformer.ts
  44. 23 19
      src/node-transformers/obfuscating-transformers/ImportDeclarationTransformer.ts
  45. 15 11
      src/node-transformers/obfuscating-transformers/LabeledStatementTransformer.ts
  46. 23 18
      src/node-transformers/obfuscating-transformers/VariableDeclarationTransformer.ts
  47. 3 3
      src/node-transformers/obfuscating-transformers/obfuscating-replacers/AbstractObfuscatingReplacer.ts
  48. 17 17
      src/node-transformers/obfuscating-transformers/obfuscating-replacers/identifier-obfuscating-replacers/BaseIdentifierObfuscatingReplacer.ts
  49. 42 39
      src/node/NodeAppender.ts
  50. 4 14
      src/node/NodeFactory.ts
  51. 28 41
      src/node/NodeGuards.ts
  52. 57 0
      src/node/NodeLexicalScopeUtils.ts
  53. 135 0
      src/node/NodeStatementUtils.ts
  54. 0 144
      src/node/NodeUtils.ts
  55. 41 27
      src/source-code/ObfuscatedCode.ts
  56. 43 0
      src/source-code/SourceCode.ts
  57. 1 1
      src/types/TObject.d.ts
  58. 0 3
      src/types/container/TObfuscationResultFactory.d.ts
  59. 3 0
      src/types/container/source-code/TObfuscatedCodeFactory.d.ts
  60. 0 3
      src/types/node/TNodeWithBlockScope.d.ts
  61. 3 0
      src/types/node/TNodeWithLexicalScope.d.ts
  62. 0 3
      src/types/node/TNodeWithScope.d.ts
  63. 3 0
      src/types/node/TNodeWithStatements.d.ts
  64. 0 1
      src/types/source-map/TSourceMapMode.d.ts
  65. 1 14
      src/utils/RandomGenerator.ts
  66. 2 5
      test/dev/dev.ts
  67. 12 12
      test/functional-tests/analyzers/stack-trace-analyzer/StackTraceAnalyzer.spec.ts
  68. 6 10
      test/functional-tests/custom-nodes/console-output-nodes/ConsoleOutputDisableExpressionNode.spec.ts
  69. 6 10
      test/functional-tests/custom-nodes/domain-lock-nodes/DomainLockNode.spec.ts
  70. 4 10
      test/functional-tests/custom-nodes/string-array-nodes/StringArrayCallsWrapper.spec.ts
  71. 4 10
      test/functional-tests/custom-nodes/string-array-nodes/StringArrayNode.spec.ts
  72. 4 10
      test/functional-tests/custom-nodes/string-array-nodes/StringArrayRotateFunctionNode.spec.ts
  73. 70 96
      test/functional-tests/javascript-obfuscator/JavaScriptObfuscator.spec.ts
  74. 47 64
      test/functional-tests/node-transformers/control-flow-transformers/block-statement-control-flow-transformer/BlockStatementControlFlowTransformer.spec.ts
  75. 6 12
      test/functional-tests/node-transformers/control-flow-transformers/control-flow-replacers/binary-expression-control-flow-replacer/BinaryExpressionControlFlowReplacer.spec.ts
  76. 9 16
      test/functional-tests/node-transformers/control-flow-transformers/control-flow-replacers/call-expression-control-flow-replacer/CallExpressionControlFlowReplacer.spec.ts
  77. 12 20
      test/functional-tests/node-transformers/control-flow-transformers/control-flow-replacers/logical-expression-control-flow-replacer/LogicalExpressionControlFlowReplacer.spec.ts
  78. 3 6
      test/functional-tests/node-transformers/control-flow-transformers/control-flow-replacers/string-litertal-control-flow-replacer/StringLiteralControlFlowReplacer.spec.ts
  79. 24 34
      test/functional-tests/node-transformers/control-flow-transformers/function-control-flow-transformer/FunctionControlFlowTransformer.spec.ts
  80. 12 18
      test/functional-tests/node-transformers/converting-transformers/member-expression-transformer/MemberExpressionTransformer.spec.ts
  81. 12 18
      test/functional-tests/node-transformers/converting-transformers/method-definition-transformer/MethodDefinitionTransformer.spec.ts
  82. 54 74
      test/functional-tests/node-transformers/converting-transformers/object-expression-keys-transformer/ObjectExpressionKeysTransformer.spec.ts
  83. 24 34
      test/functional-tests/node-transformers/converting-transformers/object-expression-transformer/ObjectExpressionTransformer.spec.ts
  84. 46 35
      test/functional-tests/node-transformers/converting-transformers/template-literal-transformer/TemplateLiteralTransformer.spec.ts
  85. 42 49
      test/functional-tests/node-transformers/dead-code-injection-transformers/DeadCodeInjectionTransformer.spec.ts
  86. 6 10
      test/functional-tests/node-transformers/obfuscating-transformers/catch-clause-transformer/CatchClauseTransformer.spec.ts
  87. 21 30
      test/functional-tests/node-transformers/obfuscating-transformers/class-declaration-transformer/ClassDeclarationTransformer.spec.ts
  88. 24 34
      test/functional-tests/node-transformers/obfuscating-transformers/function-declaration-transformer/FunctionDeclarationTransformer.spec.ts
  89. 154 42
      test/functional-tests/node-transformers/obfuscating-transformers/function-transformer/FunctionTransformer.spec.ts
  90. 6 0
      test/functional-tests/node-transformers/obfuscating-transformers/function-transformer/fixtures/arrow-function-with-expression-body-block-scope-detection-1.js
  91. 4 0
      test/functional-tests/node-transformers/obfuscating-transformers/function-transformer/fixtures/arrow-function-with-expression-body-block-scope-detection-2.js
  92. 3 0
      test/functional-tests/node-transformers/obfuscating-transformers/function-transformer/fixtures/identifier-names-set-object-pattern.js
  93. 1 0
      test/functional-tests/node-transformers/obfuscating-transformers/function-transformer/fixtures/object-pattern-as-parameter-2.js
  94. 11 0
      test/functional-tests/node-transformers/obfuscating-transformers/function-transformer/fixtures/object-pattern-as-parameter-3.js
  95. 15 22
      test/functional-tests/node-transformers/obfuscating-transformers/impot-declaration-transformer/ImportDeclarationTransformer.spec.ts
  96. 3 6
      test/functional-tests/node-transformers/obfuscating-transformers/labeled-statement-transformer/LabeledStatementTransformer.spec.ts
  97. 56 76
      test/functional-tests/node-transformers/obfuscating-transformers/literal-transformer/LiteralTransformer.spec.ts
  98. 60 80
      test/functional-tests/node-transformers/obfuscating-transformers/variable-declaration-transformer/VariableDeclarationTransformer.spec.ts
  99. 18 26
      test/functional-tests/node-transformers/preparing-transformers/comments-transformer/CommentsTransformer.spec.ts
  100. 27 38
      test/functional-tests/node-transformers/preparing-transformers/eval-call-expression-transformer/EvalCallExpressionTransformer.spec.ts

+ 4 - 0
CHANGELOG.md

@@ -4,6 +4,10 @@ v0.18.0
 ---
 ---
 * **New option:** `reservedStrings` disables transformation of string literals, which being matched by passed RegExp patterns
 * **New option:** `reservedStrings` disables transformation of string literals, which being matched by passed RegExp patterns
 
 
+v0.17.2
+---
+* Fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/297
+
 v0.17.1
 v0.17.1
 ---
 ---
 * Fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/293
 * Fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/293

Plik diff jest za duży
+ 0 - 0
dist/index.browser.js


Plik diff jest za duży
+ 0 - 0
dist/index.cli.js


Plik diff jest za duży
+ 0 - 0
dist/index.js


+ 16 - 16
package.json

@@ -1,6 +1,6 @@
 {
 {
   "name": "javascript-obfuscator",
   "name": "javascript-obfuscator",
-  "version": "0.18.0-dev.1",
+  "version": "0.18.0-dev.2",
   "description": "JavaScript obfuscator",
   "description": "JavaScript obfuscator",
   "keywords": [
   "keywords": [
     "obfuscator",
     "obfuscator",
@@ -21,12 +21,12 @@
   },
   },
   "types": "index.d.ts",
   "types": "index.d.ts",
   "dependencies": {
   "dependencies": {
-    "@babel/runtime": "7.0.0-beta.53",
+    "@babel/runtime": "7.0.0-beta.55",
     "chalk": "2.4.1",
     "chalk": "2.4.1",
     "chance": "1.0.16",
     "chance": "1.0.16",
-    "class-validator": "0.8.5",
+    "class-validator": "0.9.1",
     "commander": "2.16.0",
     "commander": "2.16.0",
-    "escodegen-wallaby": "1.6.18",
+    "escodegen-wallaby": "1.6.19",
     "espree": "4.0.0",
     "espree": "4.0.0",
     "estraverse": "4.2.0",
     "estraverse": "4.2.0",
     "inversify": "4.13.0",
     "inversify": "4.13.0",
@@ -41,10 +41,10 @@
     "tslib": "1.9.3"
     "tslib": "1.9.3"
   },
   },
   "devDependencies": {
   "devDependencies": {
-    "@babel/cli": "7.0.0-beta.53",
-    "@babel/core": "7.0.0-beta.53",
-    "@babel/plugin-transform-runtime": "7.0.0-beta.53",
-    "@babel/preset-env": "7.0.0-beta.53",
+    "@babel/cli": "7.0.0-beta.55",
+    "@babel/core": "7.0.0-beta.55",
+    "@babel/plugin-transform-runtime": "7.0.0-beta.55",
+    "@babel/preset-env": "7.0.0-beta.55",
     "@types/chai": "4.1.4",
     "@types/chai": "4.1.4",
     "@types/chance": "1.0.1",
     "@types/chance": "1.0.1",
     "@types/escodegen": "0.0.6",
     "@types/escodegen": "0.0.6",
@@ -52,9 +52,9 @@
     "@types/estree": "0.0.38",
     "@types/estree": "0.0.38",
     "@types/md5": "2.1.32",
     "@types/md5": "2.1.32",
     "@types/mkdirp": "0.5.2",
     "@types/mkdirp": "0.5.2",
-    "@types/mocha": "5.2.4",
+    "@types/mocha": "5.2.5",
     "@types/multimatch": "2.1.2",
     "@types/multimatch": "2.1.2",
-    "@types/node": "10.5.2",
+    "@types/node": "10.5.4",
     "@types/rimraf": "2.0.2",
     "@types/rimraf": "2.0.2",
     "@types/sinon": "5.0.1",
     "@types/sinon": "5.0.1",
     "@types/string-template": "1.0.2",
     "@types/string-template": "1.0.2",
@@ -68,17 +68,17 @@
     "pjson": "1.0.9",
     "pjson": "1.0.9",
     "pre-commit": "1.2.2",
     "pre-commit": "1.2.2",
     "rimraf": "2.6.2",
     "rimraf": "2.6.2",
-    "sinon": "6.1.3",
+    "sinon": "6.1.4",
     "threads": "0.12.0",
     "threads": "0.12.0",
     "ts-node": "6.1.0",
     "ts-node": "6.1.0",
-    "tslint": "5.10.0",
+    "tslint": "5.11.0",
     "tslint-eslint-rules": "5.3.1",
     "tslint-eslint-rules": "5.3.1",
     "tslint-language-service": "0.9.9",
     "tslint-language-service": "0.9.9",
-    "tslint-microsoft-contrib": "5.0.3",
+    "tslint-microsoft-contrib": "5.1.0",
     "tslint-webpack-plugin": "1.2.2",
     "tslint-webpack-plugin": "1.2.2",
-    "typescript": "2.9.2",
-    "webpack": "4.16.0",
-    "webpack-cli": "3.0.8",
+    "typescript": "3.0.1",
+    "webpack": "4.16.3",
+    "webpack-cli": "3.1.0",
     "webpack-node-externals": "1.7.2"
     "webpack-node-externals": "1.7.2"
   },
   },
   "repository": {
   "repository": {

+ 17 - 19
src/JavaScriptObfuscator.ts

@@ -5,13 +5,14 @@ import * as escodegen from 'escodegen-wallaby';
 import * as espree from 'espree';
 import * as espree from 'espree';
 import * as ESTree from 'estree';
 import * as ESTree from 'estree';
 
 
+import { TObfuscatedCodeFactory } from './types/container/source-code/TObfuscatedCodeFactory';
+
 import { IGeneratorOutput } from './interfaces/IGeneratorOutput';
 import { IGeneratorOutput } from './interfaces/IGeneratorOutput';
 import { IJavaScriptObfuscator } from './interfaces/IJavaScriptObfsucator';
 import { IJavaScriptObfuscator } from './interfaces/IJavaScriptObfsucator';
 import { ILogger } from './interfaces/logger/ILogger';
 import { ILogger } from './interfaces/logger/ILogger';
-import { IObfuscationResult } from './interfaces/IObfuscationResult';
+import { IObfuscatedCode } from './interfaces/source-code/IObfuscatedCode';
 import { IOptions } from './interfaces/options/IOptions';
 import { IOptions } from './interfaces/options/IOptions';
 import { IRandomGenerator } from './interfaces/utils/IRandomGenerator';
 import { IRandomGenerator } from './interfaces/utils/IRandomGenerator';
-import { ISourceMapCorrector } from './interfaces/source-map/ISourceMapCorrector';
 import { ITransformersRunner } from './interfaces/node-transformers/ITransformersRunner';
 import { ITransformersRunner } from './interfaces/node-transformers/ITransformersRunner';
 
 
 import { LoggingMessage } from './enums/logger/LoggingMessage';
 import { LoggingMessage } from './enums/logger/LoggingMessage';
@@ -79,6 +80,11 @@ export class JavaScriptObfuscator implements IJavaScriptObfuscator {
      */
      */
     private readonly logger: ILogger;
     private readonly logger: ILogger;
 
 
+    /**
+     * @type {TObfuscatedCodeFactory}
+     */
+    private readonly obfuscatedCodeFactory: TObfuscatedCodeFactory;
+
     /**
     /**
      * @type {IOptions}
      * @type {IOptions}
      */
      */
@@ -89,11 +95,6 @@ export class JavaScriptObfuscator implements IJavaScriptObfuscator {
      */
      */
     private readonly randomGenerator: IRandomGenerator;
     private readonly randomGenerator: IRandomGenerator;
 
 
-    /**
-     * @type {ISourceMapCorrector}
-     */
-    private readonly sourceMapCorrector: ISourceMapCorrector;
-
     /**
     /**
      * @type {ITransformersRunner}
      * @type {ITransformersRunner}
      */
      */
@@ -101,30 +102,30 @@ export class JavaScriptObfuscator implements IJavaScriptObfuscator {
 
 
     /**
     /**
      * @param {ITransformersRunner} transformersRunner
      * @param {ITransformersRunner} transformersRunner
-     * @param {ISourceMapCorrector} sourceMapCorrector
      * @param {IRandomGenerator} randomGenerator
      * @param {IRandomGenerator} randomGenerator
+     * @param {TObfuscatedCodeFactory} obfuscatedCodeFactory
      * @param {ILogger} logger
      * @param {ILogger} logger
      * @param {IOptions} options
      * @param {IOptions} options
      */
      */
     constructor (
     constructor (
         @inject(ServiceIdentifiers.ITransformersRunner) transformersRunner: ITransformersRunner,
         @inject(ServiceIdentifiers.ITransformersRunner) transformersRunner: ITransformersRunner,
-        @inject(ServiceIdentifiers.ISourceMapCorrector) sourceMapCorrector: ISourceMapCorrector,
         @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
         @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
+        @inject(ServiceIdentifiers.Factory__IObfuscatedCode) obfuscatedCodeFactory: TObfuscatedCodeFactory,
         @inject(ServiceIdentifiers.ILogger) logger: ILogger,
         @inject(ServiceIdentifiers.ILogger) logger: ILogger,
         @inject(ServiceIdentifiers.IOptions) options: IOptions
         @inject(ServiceIdentifiers.IOptions) options: IOptions
     ) {
     ) {
         this.transformersRunner = transformersRunner;
         this.transformersRunner = transformersRunner;
-        this.sourceMapCorrector = sourceMapCorrector;
         this.randomGenerator = randomGenerator;
         this.randomGenerator = randomGenerator;
+        this.obfuscatedCodeFactory = obfuscatedCodeFactory;
         this.logger = logger;
         this.logger = logger;
         this.options = options;
         this.options = options;
     }
     }
 
 
     /**
     /**
      * @param {string} sourceCode
      * @param {string} sourceCode
-     * @returns {IObfuscationResult}
+     * @returns {IObfuscatedCode}
      */
      */
-    public obfuscate (sourceCode: string): IObfuscationResult {
+    public obfuscate (sourceCode: string): IObfuscatedCode {
         const timeStart: number = Date.now();
         const timeStart: number = Date.now();
         this.logger.info(LoggingMessage.Version, process.env.VERSION);
         this.logger.info(LoggingMessage.Version, process.env.VERSION);
         this.logger.info(LoggingMessage.ObfuscationStarted);
         this.logger.info(LoggingMessage.ObfuscationStarted);
@@ -142,7 +143,7 @@ export class JavaScriptObfuscator implements IJavaScriptObfuscator {
         const obfuscationTime: number = (Date.now() - timeStart) / 1000;
         const obfuscationTime: number = (Date.now() - timeStart) / 1000;
         this.logger.success(LoggingMessage.ObfuscationCompleted, obfuscationTime);
         this.logger.success(LoggingMessage.ObfuscationCompleted, obfuscationTime);
 
 
-        return this.getObfuscationResult(generatorOutput);
+        return this.getObfuscatedCode(generatorOutput);
     }
     }
 
 
     /**
     /**
@@ -215,13 +216,10 @@ export class JavaScriptObfuscator implements IJavaScriptObfuscator {
 
 
     /**
     /**
      * @param {IGeneratorOutput} generatorOutput
      * @param {IGeneratorOutput} generatorOutput
-     * @returns {IObfuscationResult}
+     * @returns {IObfuscatedCode}
      */
      */
-    private getObfuscationResult (generatorOutput: IGeneratorOutput): IObfuscationResult {
-        return this.sourceMapCorrector.correct(
-            generatorOutput.code,
-            generatorOutput.map
-        );
+    private getObfuscatedCode (generatorOutput: IGeneratorOutput): IObfuscatedCode {
+        return this.obfuscatedCodeFactory(generatorOutput.code, generatorOutput.map);
     }
     }
 
 
     /**
     /**

+ 6 - 6
src/JavaScriptObfuscatorFacade.ts

@@ -6,7 +6,7 @@ import { TInputOptions } from './types/options/TInputOptions';
 
 
 import { IInversifyContainerFacade } from './interfaces/container/IInversifyContainerFacade';
 import { IInversifyContainerFacade } from './interfaces/container/IInversifyContainerFacade';
 import { IJavaScriptObfuscator } from './interfaces/IJavaScriptObfsucator';
 import { IJavaScriptObfuscator } from './interfaces/IJavaScriptObfsucator';
-import { IObfuscationResult } from './interfaces/IObfuscationResult';
+import { IObfuscatedCode } from './interfaces/source-code/IObfuscatedCode';
 
 
 import { InversifyContainerFacade } from './container/InversifyContainerFacade';
 import { InversifyContainerFacade } from './container/InversifyContainerFacade';
 
 
@@ -19,20 +19,20 @@ class JavaScriptObfuscatorFacade {
     /**
     /**
      * @param {string} sourceCode
      * @param {string} sourceCode
      * @param {TInputOptions} inputOptions
      * @param {TInputOptions} inputOptions
-     * @returns {IObfuscationResult}
+     * @returns {IObfuscatedCode}
      */
      */
-    public static obfuscate (sourceCode: string, inputOptions: TInputOptions = {}): IObfuscationResult {
+    public static obfuscate (sourceCode: string, inputOptions: TInputOptions = {}): IObfuscatedCode {
         const inversifyContainerFacade: IInversifyContainerFacade = new InversifyContainerFacade();
         const inversifyContainerFacade: IInversifyContainerFacade = new InversifyContainerFacade();
 
 
-        inversifyContainerFacade.load(sourceCode, inputOptions);
+        inversifyContainerFacade.load(sourceCode, '', inputOptions);
 
 
         const javaScriptObfuscator: IJavaScriptObfuscator = inversifyContainerFacade
         const javaScriptObfuscator: IJavaScriptObfuscator = inversifyContainerFacade
             .get<IJavaScriptObfuscator>(ServiceIdentifiers.IJavaScriptObfuscator);
             .get<IJavaScriptObfuscator>(ServiceIdentifiers.IJavaScriptObfuscator);
-        const obfuscationResult: IObfuscationResult = javaScriptObfuscator.obfuscate(sourceCode);
+        const obfuscatedCode: IObfuscatedCode = javaScriptObfuscator.obfuscate(sourceCode);
 
 
         inversifyContainerFacade.unload();
         inversifyContainerFacade.unload();
 
 
-        return obfuscationResult;
+        return obfuscatedCode;
     }
     }
 }
 }
 
 

+ 0 - 50
src/ObfuscationResult.ts

@@ -1,50 +0,0 @@
-import { injectable } from 'inversify';
-
-import { IObfuscationResult } from './interfaces/IObfuscationResult';
-
-import { initializable } from './decorators/Initializable';
-
-@injectable()
-export class ObfuscationResult implements IObfuscationResult {
-    /**
-     * @type {string}
-     */
-    @initializable()
-    private obfuscatedCode!: string;
-
-    /**
-     * @type {string}
-     */
-    @initializable()
-    private sourceMap!: string;
-
-    /**
-     * @param {string} obfuscatedCode
-     * @param {string} sourceMap
-     */
-    public initialize (obfuscatedCode: string, sourceMap: string): void {
-        this.obfuscatedCode = obfuscatedCode;
-        this.sourceMap = sourceMap;
-    }
-
-    /**
-     * @returns {string}
-     */
-    public getObfuscatedCode (): string {
-        return this.obfuscatedCode;
-    }
-
-    /**
-     * @returns {string}
-     */
-    public getSourceMap (): string {
-        return this.sourceMap;
-    }
-
-    /**
-     * @returns {string}
-     */
-    public toString (): string {
-        return this.obfuscatedCode;
-    }
-}

+ 0 - 22
src/SourceCode.ts

@@ -1,22 +0,0 @@
-import { ISourceCode } from './interfaces/ISourceCode';
-
-export class SourceCode implements ISourceCode {
-    /**
-     * @type {string}
-     */
-    private readonly sourceCode: string;
-
-    /**
-     * @param {string} sourceCode
-     */
-    constructor (sourceCode: string) {
-        this.sourceCode = sourceCode;
-    }
-
-    /**
-     * @returns {string}
-     */
-    public getSourceCode (): string {
-        return this.sourceCode;
-    }
-}

+ 2 - 2
src/analyzers/stack-trace-analyzer/StackTraceAnalyzer.ts

@@ -13,7 +13,7 @@ import { IStackTraceData } from '../../interfaces/analyzers/stack-trace-analyzer
 import { CalleeDataExtractor } from '../../enums/analyzers/stack-trace-analyzer/CalleeDataExtractor';
 import { CalleeDataExtractor } from '../../enums/analyzers/stack-trace-analyzer/CalleeDataExtractor';
 
 
 import { NodeGuards } from '../../node/NodeGuards';
 import { NodeGuards } from '../../node/NodeGuards';
-import { NodeUtils } from '../../node/NodeUtils';
+import { NodeStatementUtils } from '../../node/NodeStatementUtils';
 
 
 /**
 /**
  * This class generates a data with a stack trace of functions calls
  * This class generates a data with a stack trace of functions calls
@@ -131,7 +131,7 @@ export class StackTraceAnalyzer implements IStackTraceAnalyzer {
                         return;
                         return;
                     }
                     }
 
 
-                    if (blockScopeBodyNode.parentNode !== NodeUtils.getBlockScopeOfNode(node)) {
+                    if (blockScopeBodyNode.parentNode !== NodeStatementUtils.getParentNodeWithStatements(node)) {
                         return estraverse.VisitorOption.Skip;
                         return estraverse.VisitorOption.Skip;
                     }
                     }
 
 

+ 2 - 2
src/analyzers/stack-trace-analyzer/callee-data-extractors/FunctionDeclarationCalleeDataExtractor.ts

@@ -7,7 +7,7 @@ import { ICalleeData } from '../../../interfaces/analyzers/stack-trace-analyzer/
 
 
 import { AbstractCalleeDataExtractor } from './AbstractCalleeDataExtractor';
 import { AbstractCalleeDataExtractor } from './AbstractCalleeDataExtractor';
 import { NodeGuards } from '../../../node/NodeGuards';
 import { NodeGuards } from '../../../node/NodeGuards';
-import { NodeUtils } from '../../../node/NodeUtils';
+import { NodeStatementUtils } from '../../../node/NodeStatementUtils';
 
 
 @injectable()
 @injectable()
 export class FunctionDeclarationCalleeDataExtractor extends AbstractCalleeDataExtractor {
 export class FunctionDeclarationCalleeDataExtractor extends AbstractCalleeDataExtractor {
@@ -22,7 +22,7 @@ export class FunctionDeclarationCalleeDataExtractor extends AbstractCalleeDataEx
         }
         }
 
 
         const calleeBlockStatement: ESTree.BlockStatement | null = this.getCalleeBlockStatement(
         const calleeBlockStatement: ESTree.BlockStatement | null = this.getCalleeBlockStatement(
-            NodeUtils.getBlockScopeOfNode(blockScopeBody[0]),
+            NodeStatementUtils.getParentNodeWithStatements(blockScopeBody[0]),
             callee.name
             callee.name
         );
         );
 
 

+ 2 - 2
src/analyzers/stack-trace-analyzer/callee-data-extractors/FunctionExpressionCalleeDataExtractor.ts

@@ -7,7 +7,7 @@ import { ICalleeData } from '../../../interfaces/analyzers/stack-trace-analyzer/
 
 
 import { AbstractCalleeDataExtractor } from './AbstractCalleeDataExtractor';
 import { AbstractCalleeDataExtractor } from './AbstractCalleeDataExtractor';
 import { NodeGuards } from '../../../node/NodeGuards';
 import { NodeGuards } from '../../../node/NodeGuards';
-import { NodeUtils } from '../../../node/NodeUtils';
+import { NodeStatementUtils } from '../../../node/NodeStatementUtils';
 
 
 @injectable()
 @injectable()
 export class FunctionExpressionCalleeDataExtractor extends AbstractCalleeDataExtractor {
 export class FunctionExpressionCalleeDataExtractor extends AbstractCalleeDataExtractor {
@@ -21,7 +21,7 @@ export class FunctionExpressionCalleeDataExtractor extends AbstractCalleeDataExt
 
 
         if (NodeGuards.isIdentifierNode(callee)) {
         if (NodeGuards.isIdentifierNode(callee)) {
             calleeBlockStatement = this.getCalleeBlockStatement(
             calleeBlockStatement = this.getCalleeBlockStatement(
-                NodeUtils.getBlockScopeOfNode(blockScopeBody[0]),
+                NodeStatementUtils.getParentNodeWithStatements(blockScopeBody[0]),
                 callee.name
                 callee.name
             );
             );
         }
         }

+ 2 - 2
src/analyzers/stack-trace-analyzer/callee-data-extractors/ObjectExpressionCalleeDataExtractor.ts

@@ -9,7 +9,7 @@ import { ICalleeData } from '../../../interfaces/analyzers/stack-trace-analyzer/
 
 
 import { AbstractCalleeDataExtractor } from './AbstractCalleeDataExtractor';
 import { AbstractCalleeDataExtractor } from './AbstractCalleeDataExtractor';
 import { NodeGuards } from '../../../node/NodeGuards';
 import { NodeGuards } from '../../../node/NodeGuards';
-import { NodeUtils } from '../../../node/NodeUtils';
+import { NodeStatementUtils } from '../../../node/NodeStatementUtils';
 
 
 @injectable()
 @injectable()
 export class ObjectExpressionCalleeDataExtractor extends AbstractCalleeDataExtractor {
 export class ObjectExpressionCalleeDataExtractor extends AbstractCalleeDataExtractor {
@@ -51,7 +51,7 @@ export class ObjectExpressionCalleeDataExtractor extends AbstractCalleeDataExtra
 
 
         const functionExpressionName: string | number | null = objectMembersCallsChain[objectMembersCallsChain.length - 1];
         const functionExpressionName: string | number | null = objectMembersCallsChain[objectMembersCallsChain.length - 1];
         const calleeBlockStatement: ESTree.BlockStatement | null = this.getCalleeBlockStatement(
         const calleeBlockStatement: ESTree.BlockStatement | null = this.getCalleeBlockStatement(
-            NodeUtils.getBlockScopeOfNode(blockScopeBody[0]),
+            NodeStatementUtils.getParentNodeWithStatements(blockScopeBody[0]),
             objectMembersCallsChain
             objectMembersCallsChain
         );
         );
 
 

+ 5 - 5
src/cli/JavaScriptObfuscatorCLI.ts

@@ -7,7 +7,7 @@ import { TSourceCodeData } from '../types/cli/TSourceCodeData';
 
 
 import { IFileData } from '../interfaces/cli/IFileData';
 import { IFileData } from '../interfaces/cli/IFileData';
 import { IInitializable } from '../interfaces/IInitializable';
 import { IInitializable } from '../interfaces/IInitializable';
-import { IObfuscationResult } from '../interfaces/IObfuscationResult';
+import { IObfuscatedCode } from '../interfaces/source-code/IObfuscatedCode';
 
 
 import { initializable } from '../decorators/Initializable';
 import { initializable } from '../decorators/Initializable';
 
 
@@ -131,12 +131,12 @@ export class JavaScriptObfuscatorCLI implements IInitializable {
             sourceMapFileName: path.basename(outputSourceMapPath)
             sourceMapFileName: path.basename(outputSourceMapPath)
         };
         };
 
 
-        const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(sourceCode, options);
+        const obfuscatedCode: IObfuscatedCode = JavaScriptObfuscator.obfuscate(sourceCode, options);
 
 
-        CLIUtils.writeFile(outputCodePath, obfuscationResult.getObfuscatedCode());
+        CLIUtils.writeFile(outputCodePath, obfuscatedCode.getObfuscatedCode());
 
 
-        if (options.sourceMapMode === 'separate' && obfuscationResult.getSourceMap()) {
-            CLIUtils.writeFile(outputSourceMapPath, obfuscationResult.getSourceMap());
+        if (options.sourceMapMode === 'separate' && obfuscatedCode.getSourceMap()) {
+            CLIUtils.writeFile(outputSourceMapPath, obfuscatedCode.getSourceMap());
         }
         }
     }
     }
 
 

+ 16 - 23
src/container/InversifyContainerFacade.ts

@@ -20,17 +20,15 @@ import { IInversifyContainerFacade } from '../interfaces/container/IInversifyCon
 import { IJavaScriptObfuscator } from '../interfaces/IJavaScriptObfsucator';
 import { IJavaScriptObfuscator } from '../interfaces/IJavaScriptObfsucator';
 import { ILogger } from '../interfaces/logger/ILogger';
 import { ILogger } from '../interfaces/logger/ILogger';
 import { IObfuscationEventEmitter } from '../interfaces/event-emitters/IObfuscationEventEmitter';
 import { IObfuscationEventEmitter } from '../interfaces/event-emitters/IObfuscationEventEmitter';
-import { IObfuscationResult } from '../interfaces/IObfuscationResult';
-import { ISourceCode } from '../interfaces/ISourceCode';
-import { ISourceMapCorrector } from '../interfaces/source-map/ISourceMapCorrector';
+import { IObfuscatedCode } from '../interfaces/source-code/IObfuscatedCode';
+import { ISourceCode } from '../interfaces/source-code/ISourceCode';
 import { ITransformersRunner } from '../interfaces/node-transformers/ITransformersRunner';
 import { ITransformersRunner } from '../interfaces/node-transformers/ITransformersRunner';
 
 
 import { JavaScriptObfuscator } from '../JavaScriptObfuscator';
 import { JavaScriptObfuscator } from '../JavaScriptObfuscator';
 import { Logger } from '../logger/Logger';
 import { Logger } from '../logger/Logger';
 import { ObfuscationEventEmitter } from '../event-emitters/ObfuscationEventEmitter';
 import { ObfuscationEventEmitter } from '../event-emitters/ObfuscationEventEmitter';
-import { ObfuscationResult } from '../ObfuscationResult';
-import { SourceCode } from '../SourceCode';
-import { SourceMapCorrector } from '../source-map/SourceMapCorrector';
+import { ObfuscatedCode } from '../source-code/ObfuscatedCode';
+import { SourceCode } from '../source-code/SourceCode';
 import { TransformersRunner } from '../node-transformers/TransformersRunner';
 import { TransformersRunner } from '../node-transformers/TransformersRunner';
 
 
 export class InversifyContainerFacade implements IInversifyContainerFacade {
 export class InversifyContainerFacade implements IInversifyContainerFacade {
@@ -140,12 +138,13 @@ export class InversifyContainerFacade implements IInversifyContainerFacade {
 
 
     /**
     /**
      * @param {string} sourceCode
      * @param {string} sourceCode
+     * @param {string} sourceMap
      * @param {TInputOptions} options
      * @param {TInputOptions} options
      */
      */
-    public load (sourceCode: string, options: TInputOptions): void {
+    public load (sourceCode: string, sourceMap: string, options: TInputOptions): void {
         this.container
         this.container
             .bind<ISourceCode>(ServiceIdentifiers.ISourceCode)
             .bind<ISourceCode>(ServiceIdentifiers.ISourceCode)
-            .toDynamicValue(() => new SourceCode(sourceCode))
+            .toDynamicValue(() => new SourceCode(sourceCode, sourceMap))
             .inSingletonScope();
             .inSingletonScope();
 
 
         this.container
         this.container
@@ -169,28 +168,22 @@ export class InversifyContainerFacade implements IInversifyContainerFacade {
             .inSingletonScope();
             .inSingletonScope();
 
 
         this.container
         this.container
-            .bind<IObfuscationResult>(ServiceIdentifiers.IObfuscationResult)
-            .to(ObfuscationResult)
-            .inSingletonScope();
+            .bind<IObfuscatedCode>(ServiceIdentifiers.IObfuscatedCode)
+            .to(ObfuscatedCode);
 
 
         this.container
         this.container
-            .bind<IObfuscationResult>(ServiceIdentifiers.Factory__IObfuscationResult)
-            .toFactory<IObfuscationResult>((context: interfaces.Context) => {
-                return (obfuscatedCode: string, sourceMap: string) => {
-                    const obfuscationResult: IObfuscationResult = context.container
-                        .get<IObfuscationResult>(ServiceIdentifiers.IObfuscationResult);
+            .bind<IObfuscatedCode>(ServiceIdentifiers.Factory__IObfuscatedCode)
+            .toFactory<IObfuscatedCode>((context: interfaces.Context) => {
+                return (obfuscatedCodeAsString: string, sourceMapAsString: string) => {
+                    const obfuscatedCode: IObfuscatedCode = context.container
+                        .get<IObfuscatedCode>(ServiceIdentifiers.IObfuscatedCode);
 
 
-                    obfuscationResult.initialize(obfuscatedCode, sourceMap);
+                    obfuscatedCode.initialize(obfuscatedCodeAsString, sourceMapAsString);
 
 
-                    return obfuscationResult;
+                    return obfuscatedCode;
                 };
                 };
             });
             });
 
 
-        this.container
-            .bind<ISourceMapCorrector>(ServiceIdentifiers.ISourceMapCorrector)
-            .to(SourceMapCorrector)
-            .inSingletonScope();
-
         this.container
         this.container
             .bind<IObfuscationEventEmitter>(ServiceIdentifiers.IObfuscationEventEmitter)
             .bind<IObfuscationEventEmitter>(ServiceIdentifiers.IObfuscationEventEmitter)
             .to(ObfuscationEventEmitter)
             .to(ObfuscationEventEmitter)

+ 2 - 2
src/container/ServiceIdentifiers.ts

@@ -9,7 +9,7 @@ export enum ServiceIdentifiers {
     Factory__IIdentifierObfuscatingReplacer = 'Factory<IIdentifierObfuscatingReplacer>',
     Factory__IIdentifierObfuscatingReplacer = 'Factory<IIdentifierObfuscatingReplacer>',
     Factory__INodeGuard = 'Factory<INodeGuard>',
     Factory__INodeGuard = 'Factory<INodeGuard>',
     Factory__INodeTransformer = 'Factory<INodeTransformer[]>',
     Factory__INodeTransformer = 'Factory<INodeTransformer[]>',
-    Factory__IObfuscationResult = 'Factory<IObfuscationResult>',
+    Factory__IObfuscatedCode = 'Factory<IObfuscatedCode>',
     Factory__IObfuscatingReplacer = 'Factory<IObfuscatingReplacer>',
     Factory__IObfuscatingReplacer = 'Factory<IObfuscatingReplacer>',
     Factory__IPropertiesExtractor = 'Factory<IPropertiesExtractor>',
     Factory__IPropertiesExtractor = 'Factory<IPropertiesExtractor>',
     Factory__TControlFlowStorage = 'Factory<TControlFlowStorage>',
     Factory__TControlFlowStorage = 'Factory<TControlFlowStorage>',
@@ -27,7 +27,7 @@ export enum ServiceIdentifiers {
     INodeGuard = 'INodeGuard',
     INodeGuard = 'INodeGuard',
     INodeTransformer = 'INodeTransformer',
     INodeTransformer = 'INodeTransformer',
     IObfuscationEventEmitter = 'IObfuscationEventEmitter',
     IObfuscationEventEmitter = 'IObfuscationEventEmitter',
-    IObfuscationResult = 'IObfuscationResult',
+    IObfuscatedCode = 'IObfuscatedCode',
     IOptions = 'IOptions',
     IOptions = 'IOptions',
     IOptionsNormalizer = 'IOptionsNormalizer',
     IOptionsNormalizer = 'IOptionsNormalizer',
     IObfuscatingReplacer = 'IObfuscatingReplacer',
     IObfuscatingReplacer = 'IObfuscatingReplacer',

+ 2 - 2
src/custom-nodes/AbstractCustomNode.ts

@@ -59,9 +59,9 @@ export abstract class AbstractCustomNode implements ICustomNode {
     }
     }
 
 
     /**
     /**
-     * @param {any[]} args
+     * @param {unknown[]} args
      */
      */
-    public abstract initialize (...args: any[]): void;
+    public abstract initialize (...args: unknown[]): void;
 
 
     /**
     /**
      * @returns {TStatement[]}
      * @returns {TStatement[]}

+ 3 - 3
src/custom-nodes/AbstractCustomNodeGroup.ts

@@ -2,7 +2,7 @@ import { inject, injectable } from 'inversify';
 import { ServiceIdentifiers } from '../container/ServiceIdentifiers';
 import { ServiceIdentifiers } from '../container/ServiceIdentifiers';
 
 
 import { TIdentifierNamesGeneratorFactory } from '../types/container/generators/TIdentifierNamesGeneratorFactory';
 import { TIdentifierNamesGeneratorFactory } from '../types/container/generators/TIdentifierNamesGeneratorFactory';
-import { TNodeWithBlockScope } from '../types/node/TNodeWithBlockScope';
+import { TNodeWithStatements } from '../types/node/TNodeWithStatements';
 
 
 import { ICustomNode } from '../interfaces/custom-nodes/ICustomNode';
 import { ICustomNode } from '../interfaces/custom-nodes/ICustomNode';
 import { ICustomNodeGroup } from '../interfaces/custom-nodes/ICustomNodeGroup';
 import { ICustomNodeGroup } from '../interfaces/custom-nodes/ICustomNodeGroup';
@@ -58,10 +58,10 @@ export abstract class AbstractCustomNodeGroup implements ICustomNodeGroup {
     }
     }
 
 
     /**
     /**
-     * @param {TNodeWithBlockScope} blockScopeNode
+     * @param {TNodeWithStatements} nodeWithStatements
      * @param {IStackTraceData[]} stackTraceData
      * @param {IStackTraceData[]} stackTraceData
      */
      */
-    public abstract appendCustomNodes (blockScopeNode: TNodeWithBlockScope, stackTraceData: IStackTraceData[]): void;
+    public abstract appendCustomNodes (nodeWithStatements: TNodeWithStatements, stackTraceData: IStackTraceData[]): void;
 
 
     /**
     /**
      * @returns {ObfuscationEvent}
      * @returns {ObfuscationEvent}

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

@@ -3,7 +3,7 @@ import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers';
 
 
 import { TCustomNodeFactory } from '../../../types/container/custom-nodes/TCustomNodeFactory';
 import { TCustomNodeFactory } from '../../../types/container/custom-nodes/TCustomNodeFactory';
 import { TIdentifierNamesGeneratorFactory } from '../../../types/container/generators/TIdentifierNamesGeneratorFactory';
 import { TIdentifierNamesGeneratorFactory } from '../../../types/container/generators/TIdentifierNamesGeneratorFactory';
-import { TNodeWithBlockScope } from '../../../types/node/TNodeWithBlockScope';
+import { TNodeWithStatements } from '../../../types/node/TNodeWithStatements';
 
 
 import { ICustomNode } from '../../../interfaces/custom-nodes/ICustomNode';
 import { ICustomNode } from '../../../interfaces/custom-nodes/ICustomNode';
 import { IOptions } from '../../../interfaces/options/IOptions';
 import { IOptions } from '../../../interfaces/options/IOptions';
@@ -55,17 +55,17 @@ export class ConsoleOutputCustomNodeGroup extends AbstractCustomNodeGroup {
     }
     }
 
 
     /**
     /**
-     * @param {TNodeWithBlockScope} blockScopeNode
+     * @param {TNodeWithStatements} nodeWithStatements
      * @param {IStackTraceData[]} stackTraceData
      * @param {IStackTraceData[]} stackTraceData
      */
      */
-    public appendCustomNodes (blockScopeNode: TNodeWithBlockScope, stackTraceData: IStackTraceData[]): void {
+    public appendCustomNodes (nodeWithStatements: TNodeWithStatements, stackTraceData: IStackTraceData[]): void {
         const randomStackTraceIndex: number = this.getRandomStackTraceIndex(stackTraceData.length);
         const randomStackTraceIndex: number = this.getRandomStackTraceIndex(stackTraceData.length);
 
 
         // consoleOutputDisableExpressionNode append
         // consoleOutputDisableExpressionNode append
         this.appendCustomNodeIfExist(CustomNode.ConsoleOutputDisableExpressionNode, (customNode: ICustomNode) => {
         this.appendCustomNodeIfExist(CustomNode.ConsoleOutputDisableExpressionNode, (customNode: ICustomNode) => {
             NodeAppender.appendToOptimalBlockScope(
             NodeAppender.appendToOptimalBlockScope(
                 stackTraceData,
                 stackTraceData,
-                blockScopeNode,
+                nodeWithStatements,
                 customNode.getNode(),
                 customNode.getNode(),
                 randomStackTraceIndex
                 randomStackTraceIndex
             );
             );
@@ -73,15 +73,11 @@ export class ConsoleOutputCustomNodeGroup extends AbstractCustomNodeGroup {
 
 
         // nodeCallsControllerFunctionNode append
         // nodeCallsControllerFunctionNode append
         this.appendCustomNodeIfExist(CustomNode.NodeCallsControllerFunctionNode, (customNode: ICustomNode) => {
         this.appendCustomNodeIfExist(CustomNode.NodeCallsControllerFunctionNode, (customNode: ICustomNode) => {
-            let targetBlockScope: TNodeWithBlockScope;
+            const targetNodeWithStatements: TNodeWithStatements = stackTraceData.length
+                ? NodeAppender.getOptimalBlockScope(stackTraceData, randomStackTraceIndex, 1)
+                : nodeWithStatements;
 
 
-            if (stackTraceData.length) {
-                targetBlockScope = NodeAppender.getOptimalBlockScope(stackTraceData, randomStackTraceIndex, 1);
-            } else {
-                targetBlockScope = blockScopeNode;
-            }
-
-            NodeAppender.prepend(targetBlockScope, customNode.getNode());
+            NodeAppender.prepend(targetNodeWithStatements, customNode.getNode());
         });
         });
     }
     }
 
 

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

@@ -3,7 +3,7 @@ import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers';
 
 
 import { TCustomNodeFactory } from '../../../types/container/custom-nodes/TCustomNodeFactory';
 import { TCustomNodeFactory } from '../../../types/container/custom-nodes/TCustomNodeFactory';
 import { TIdentifierNamesGeneratorFactory } from '../../../types/container/generators/TIdentifierNamesGeneratorFactory';
 import { TIdentifierNamesGeneratorFactory } from '../../../types/container/generators/TIdentifierNamesGeneratorFactory';
-import { TNodeWithBlockScope } from '../../../types/node/TNodeWithBlockScope';
+import { TNodeWithStatements } from '../../../types/node/TNodeWithStatements';
 
 
 import { ICustomNode } from '../../../interfaces/custom-nodes/ICustomNode';
 import { ICustomNode } from '../../../interfaces/custom-nodes/ICustomNode';
 import { IOptions } from '../../../interfaces/options/IOptions';
 import { IOptions } from '../../../interfaces/options/IOptions';
@@ -17,6 +17,7 @@ import { ObfuscationEvent } from '../../../enums/event-emitters/ObfuscationEvent
 
 
 import { AbstractCustomNodeGroup } from '../../AbstractCustomNodeGroup';
 import { AbstractCustomNodeGroup } from '../../AbstractCustomNodeGroup';
 import { NodeAppender } from '../../../node/NodeAppender';
 import { NodeAppender } from '../../../node/NodeAppender';
+import { NodeGuards } from '../../../node/NodeGuards';
 
 
 @injectable()
 @injectable()
 export class DebugProtectionCustomNodeGroup extends AbstractCustomNodeGroup {
 export class DebugProtectionCustomNodeGroup extends AbstractCustomNodeGroup {
@@ -55,17 +56,17 @@ export class DebugProtectionCustomNodeGroup extends AbstractCustomNodeGroup {
     }
     }
 
 
     /**
     /**
-     * @param {TNodeWithBlockScope} blockScopeNode
+     * @param {TNodeWithStatements} nodeWithStatements
      * @param {IStackTraceData[]} stackTraceData
      * @param {IStackTraceData[]} stackTraceData
      */
      */
-    public appendCustomNodes (blockScopeNode: TNodeWithBlockScope, stackTraceData: IStackTraceData[]): void {
+    public appendCustomNodes (nodeWithStatements: TNodeWithStatements, stackTraceData: IStackTraceData[]): void {
         const randomStackTraceIndex: number = this.getRandomStackTraceIndex(stackTraceData.length);
         const randomStackTraceIndex: number = this.getRandomStackTraceIndex(stackTraceData.length);
 
 
         // debugProtectionFunctionCallNode append
         // debugProtectionFunctionCallNode append
         this.appendCustomNodeIfExist(CustomNode.DebugProtectionFunctionCallNode, (customNode: ICustomNode) => {
         this.appendCustomNodeIfExist(CustomNode.DebugProtectionFunctionCallNode, (customNode: ICustomNode) => {
             NodeAppender.appendToOptimalBlockScope(
             NodeAppender.appendToOptimalBlockScope(
                 stackTraceData,
                 stackTraceData,
-                blockScopeNode,
+                nodeWithStatements,
                 customNode.getNode(),
                 customNode.getNode(),
                 randomStackTraceIndex
                 randomStackTraceIndex
             );
             );
@@ -73,28 +74,26 @@ export class DebugProtectionCustomNodeGroup extends AbstractCustomNodeGroup {
 
 
         // debugProtectionFunctionNode append
         // debugProtectionFunctionNode append
         this.appendCustomNodeIfExist(CustomNode.DebugProtectionFunctionNode, (customNode: ICustomNode) => {
         this.appendCustomNodeIfExist(CustomNode.DebugProtectionFunctionNode, (customNode: ICustomNode) => {
-            NodeAppender.append(blockScopeNode, customNode.getNode());
+            NodeAppender.append(nodeWithStatements, customNode.getNode());
         });
         });
 
 
         // debugProtectionFunctionIntervalNode append
         // debugProtectionFunctionIntervalNode append
         this.appendCustomNodeIfExist(CustomNode.DebugProtectionFunctionIntervalNode, (customNode: ICustomNode) => {
         this.appendCustomNodeIfExist(CustomNode.DebugProtectionFunctionIntervalNode, (customNode: ICustomNode) => {
-            const programBodyLength: number = blockScopeNode.body.length;
+            const programBodyLength: number = NodeGuards.isSwitchCaseNode(nodeWithStatements)
+                ? nodeWithStatements.consequent.length
+                : nodeWithStatements.body.length;
             const randomIndex: number = this.randomGenerator.getRandomInteger(0, programBodyLength);
             const randomIndex: number = this.randomGenerator.getRandomInteger(0, programBodyLength);
 
 
-            NodeAppender.insertAtIndex(blockScopeNode, customNode.getNode(), randomIndex);
+            NodeAppender.insertAtIndex(nodeWithStatements, customNode.getNode(), randomIndex);
         });
         });
 
 
         // nodeCallsControllerFunctionNode append
         // nodeCallsControllerFunctionNode append
         this.appendCustomNodeIfExist(CustomNode.NodeCallsControllerFunctionNode, (customNode: ICustomNode) => {
         this.appendCustomNodeIfExist(CustomNode.NodeCallsControllerFunctionNode, (customNode: ICustomNode) => {
-            let targetBlockScope: TNodeWithBlockScope;
+            const targetNodeWithStatements: TNodeWithStatements = stackTraceData.length
+                ? NodeAppender.getOptimalBlockScope(stackTraceData, randomStackTraceIndex, 1)
+                : nodeWithStatements;
 
 
-            if (stackTraceData.length) {
-                targetBlockScope = NodeAppender.getOptimalBlockScope(stackTraceData, randomStackTraceIndex, 1);
-            } else {
-                targetBlockScope = blockScopeNode;
-            }
-
-            NodeAppender.prepend(targetBlockScope, customNode.getNode());
+            NodeAppender.prepend(targetNodeWithStatements, customNode.getNode());
         });
         });
     }
     }
 
 

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

@@ -3,7 +3,7 @@ import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers';
 
 
 import { TCustomNodeFactory } from '../../../types/container/custom-nodes/TCustomNodeFactory';
 import { TCustomNodeFactory } from '../../../types/container/custom-nodes/TCustomNodeFactory';
 import { TIdentifierNamesGeneratorFactory } from '../../../types/container/generators/TIdentifierNamesGeneratorFactory';
 import { TIdentifierNamesGeneratorFactory } from '../../../types/container/generators/TIdentifierNamesGeneratorFactory';
-import { TNodeWithBlockScope } from '../../../types/node/TNodeWithBlockScope';
+import { TNodeWithStatements } from '../../../types/node/TNodeWithStatements';
 
 
 import { ICustomNode } from '../../../interfaces/custom-nodes/ICustomNode';
 import { ICustomNode } from '../../../interfaces/custom-nodes/ICustomNode';
 import { IOptions } from '../../../interfaces/options/IOptions';
 import { IOptions } from '../../../interfaces/options/IOptions';
@@ -55,17 +55,17 @@ export class DomainLockCustomNodeGroup extends AbstractCustomNodeGroup {
     }
     }
 
 
     /**
     /**
-     * @param {TNodeWithBlockScope} blockScopeNode
+     * @param {TNodeWithStatements} nodeWithStatements
      * @param {IStackTraceData[]} stackTraceData
      * @param {IStackTraceData[]} stackTraceData
      */
      */
-    public appendCustomNodes (blockScopeNode: TNodeWithBlockScope, stackTraceData: IStackTraceData[]): void {
+    public appendCustomNodes (nodeWithStatements: TNodeWithStatements, stackTraceData: IStackTraceData[]): void {
         const randomStackTraceIndex: number = this.getRandomStackTraceIndex(stackTraceData.length);
         const randomStackTraceIndex: number = this.getRandomStackTraceIndex(stackTraceData.length);
 
 
         // domainLockNode append
         // domainLockNode append
         this.appendCustomNodeIfExist(CustomNode.DomainLockNode, (customNode: ICustomNode) => {
         this.appendCustomNodeIfExist(CustomNode.DomainLockNode, (customNode: ICustomNode) => {
             NodeAppender.appendToOptimalBlockScope(
             NodeAppender.appendToOptimalBlockScope(
                 stackTraceData,
                 stackTraceData,
-                blockScopeNode,
+                nodeWithStatements,
                 customNode.getNode(),
                 customNode.getNode(),
                 randomStackTraceIndex
                 randomStackTraceIndex
             );
             );
@@ -73,15 +73,11 @@ export class DomainLockCustomNodeGroup extends AbstractCustomNodeGroup {
 
 
         // nodeCallsControllerFunctionNode append
         // nodeCallsControllerFunctionNode append
         this.appendCustomNodeIfExist(CustomNode.NodeCallsControllerFunctionNode, (customNode: ICustomNode) => {
         this.appendCustomNodeIfExist(CustomNode.NodeCallsControllerFunctionNode, (customNode: ICustomNode) => {
-            let targetBlockScope: TNodeWithBlockScope;
+            const targetNodeWithStatements: TNodeWithStatements = stackTraceData.length
+                ? NodeAppender.getOptimalBlockScope(stackTraceData, randomStackTraceIndex, 1)
+                : nodeWithStatements;
 
 
-            if (stackTraceData.length) {
-                targetBlockScope = NodeAppender.getOptimalBlockScope(stackTraceData, randomStackTraceIndex, 1);
-            } else {
-                targetBlockScope = blockScopeNode;
-            }
-
-            NodeAppender.prepend(targetBlockScope, customNode.getNode());
+            NodeAppender.prepend(targetNodeWithStatements, customNode.getNode());
         });
         });
     }
     }
 
 

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

@@ -3,7 +3,7 @@ import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers';
 
 
 import { TCustomNodeFactory } from '../../../types/container/custom-nodes/TCustomNodeFactory';
 import { TCustomNodeFactory } from '../../../types/container/custom-nodes/TCustomNodeFactory';
 import { TIdentifierNamesGeneratorFactory } from '../../../types/container/generators/TIdentifierNamesGeneratorFactory';
 import { TIdentifierNamesGeneratorFactory } from '../../../types/container/generators/TIdentifierNamesGeneratorFactory';
-import { TNodeWithBlockScope } from '../../../types/node/TNodeWithBlockScope';
+import { TNodeWithStatements } from '../../../types/node/TNodeWithStatements';
 
 
 import { ICustomNode } from '../../../interfaces/custom-nodes/ICustomNode';
 import { ICustomNode } from '../../../interfaces/custom-nodes/ICustomNode';
 import { IOptions } from '../../../interfaces/options/IOptions';
 import { IOptions } from '../../../interfaces/options/IOptions';
@@ -55,17 +55,17 @@ export class SelfDefendingCustomNodeGroup extends AbstractCustomNodeGroup {
     }
     }
 
 
     /**
     /**
-     * @param {TNodeWithBlockScope} blockScopeNode
+     * @param {TNodeWithStatements} nodeWithStatements
      * @param {IStackTraceData[]} stackTraceData
      * @param {IStackTraceData[]} stackTraceData
      */
      */
-    public appendCustomNodes (blockScopeNode: TNodeWithBlockScope, stackTraceData: IStackTraceData[]): void {
+    public appendCustomNodes (nodeWithStatements: TNodeWithStatements, stackTraceData: IStackTraceData[]): void {
         const randomStackTraceIndex: number = this.getRandomStackTraceIndex(stackTraceData.length);
         const randomStackTraceIndex: number = this.getRandomStackTraceIndex(stackTraceData.length);
 
 
         // selfDefendingUnicodeNode append
         // selfDefendingUnicodeNode append
         this.appendCustomNodeIfExist(CustomNode.SelfDefendingUnicodeNode, (customNode: ICustomNode) => {
         this.appendCustomNodeIfExist(CustomNode.SelfDefendingUnicodeNode, (customNode: ICustomNode) => {
             NodeAppender.appendToOptimalBlockScope(
             NodeAppender.appendToOptimalBlockScope(
                 stackTraceData,
                 stackTraceData,
-                blockScopeNode,
+                nodeWithStatements,
                 customNode.getNode(),
                 customNode.getNode(),
                 randomStackTraceIndex
                 randomStackTraceIndex
             );
             );
@@ -73,15 +73,11 @@ export class SelfDefendingCustomNodeGroup extends AbstractCustomNodeGroup {
 
 
         // nodeCallsControllerFunctionNode append
         // nodeCallsControllerFunctionNode append
         this.appendCustomNodeIfExist(CustomNode.NodeCallsControllerFunctionNode, (customNode: ICustomNode) => {
         this.appendCustomNodeIfExist(CustomNode.NodeCallsControllerFunctionNode, (customNode: ICustomNode) => {
-            let targetBlockScope: TNodeWithBlockScope;
+            const targetNodeWithStatements: TNodeWithStatements = stackTraceData.length
+                ? NodeAppender.getOptimalBlockScope(stackTraceData, randomStackTraceIndex, 1)
+                : nodeWithStatements;
 
 
-            if (stackTraceData.length) {
-                targetBlockScope = NodeAppender.getOptimalBlockScope(stackTraceData, randomStackTraceIndex, 1);
-            } else {
-                targetBlockScope = blockScopeNode;
-            }
-
-            NodeAppender.prepend(targetBlockScope, customNode.getNode());
+            NodeAppender.prepend(targetNodeWithStatements, customNode.getNode());
         });
         });
     }
     }
 
 

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

@@ -3,7 +3,7 @@ import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers';
 
 
 import { TCustomNodeFactory } from '../../../types/container/custom-nodes/TCustomNodeFactory';
 import { TCustomNodeFactory } from '../../../types/container/custom-nodes/TCustomNodeFactory';
 import { TIdentifierNamesGeneratorFactory } from '../../../types/container/generators/TIdentifierNamesGeneratorFactory';
 import { TIdentifierNamesGeneratorFactory } from '../../../types/container/generators/TIdentifierNamesGeneratorFactory';
-import { TNodeWithBlockScope } from '../../../types/node/TNodeWithBlockScope';
+import { TNodeWithStatements } from '../../../types/node/TNodeWithStatements';
 import { TStringArrayStorage } from '../../../types/storages/TStringArrayStorage';
 import { TStringArrayStorage } from '../../../types/storages/TStringArrayStorage';
 
 
 import { ICustomNode } from '../../../interfaces/custom-nodes/ICustomNode';
 import { ICustomNode } from '../../../interfaces/custom-nodes/ICustomNode';
@@ -64,27 +64,27 @@ export class StringArrayCustomNodeGroup extends AbstractCustomNodeGroup {
     }
     }
 
 
     /**
     /**
-     * @param {TNodeWithBlockScope} blockScopeNode
+     * @param {TNodeWithStatements} nodeWithStatements
      * @param {IStackTraceData[]} stackTraceData
      * @param {IStackTraceData[]} stackTraceData
      */
      */
-    public appendCustomNodes (blockScopeNode: TNodeWithBlockScope, stackTraceData: IStackTraceData[]): void {
+    public appendCustomNodes (nodeWithStatements: TNodeWithStatements, stackTraceData: IStackTraceData[]): void {
         if (!this.stringArrayStorage.getLength()) {
         if (!this.stringArrayStorage.getLength()) {
             return;
             return;
         }
         }
 
 
         // stringArrayNode append
         // stringArrayNode append
         this.appendCustomNodeIfExist(CustomNode.StringArrayNode, (customNode: ICustomNode) => {
         this.appendCustomNodeIfExist(CustomNode.StringArrayNode, (customNode: ICustomNode) => {
-            NodeAppender.prepend(blockScopeNode, customNode.getNode());
+            NodeAppender.prepend(nodeWithStatements, customNode.getNode());
         });
         });
 
 
         // stringArrayCallsWrapper append
         // stringArrayCallsWrapper append
         this.appendCustomNodeIfExist(CustomNode.StringArrayCallsWrapper, (customNode: ICustomNode) => {
         this.appendCustomNodeIfExist(CustomNode.StringArrayCallsWrapper, (customNode: ICustomNode) => {
-            NodeAppender.insertAtIndex(blockScopeNode, customNode.getNode(), 1);
+            NodeAppender.insertAtIndex(nodeWithStatements, customNode.getNode(), 1);
         });
         });
 
 
         // stringArrayRotateFunctionNode append
         // stringArrayRotateFunctionNode append
         this.appendCustomNodeIfExist(CustomNode.StringArrayRotateFunctionNode, (customNode: ICustomNode) => {
         this.appendCustomNodeIfExist(CustomNode.StringArrayRotateFunctionNode, (customNode: ICustomNode) => {
-            NodeAppender.insertAtIndex(blockScopeNode, customNode.getNode(), 1);
+            NodeAppender.insertAtIndex(nodeWithStatements, customNode.getNode(), 1);
         });
         });
     }
     }
 
 

+ 2 - 2
src/interfaces/IInitializable.d.ts

@@ -1,8 +1,8 @@
-export interface IInitializable {
+export interface IInitializable <T extends any[] = never[]> {
     [key: string]: any;
     [key: string]: any;
 
 
     /**
     /**
      * @param args
      * @param args
      */
      */
-    initialize (...args: any[]): void;
+    initialize (...args: T): void;
 }
 }

+ 3 - 3
src/interfaces/IJavaScriptObfsucator.d.ts

@@ -1,9 +1,9 @@
-import { IObfuscationResult } from './IObfuscationResult';
+import { IObfuscatedCode } from './source-code/IObfuscatedCode';
 
 
 export interface IJavaScriptObfuscator {
 export interface IJavaScriptObfuscator {
     /**
     /**
      * @param sourceCode
      * @param sourceCode
-     * @returns IObfuscationResult
+     * @returns IObfuscatedCode
      */
      */
-    obfuscate (sourceCode: string): IObfuscationResult;
+    obfuscate (sourceCode: string): IObfuscatedCode;
 }
 }

+ 4 - 3
src/interfaces/container/IInversifyContainerFacade.d.ts

@@ -15,10 +15,11 @@ export interface IInversifyContainerFacade {
     getNamed <T> (serviceIdentifier: interfaces.ServiceIdentifier<T>, named: string | number | symbol): T;
     getNamed <T> (serviceIdentifier: interfaces.ServiceIdentifier<T>, named: string | number | symbol): T;
 
 
     /**
     /**
-     * @param sourceCode
-     * @param options
+     * @param {string} sourceCode
+     * @param {string} sourceMap
+     * @param {TInputOptions} options
      */
      */
-    load (sourceCode: string, options: TInputOptions): void;
+    load (sourceCode: string, sourceMap: string, options: TInputOptions): void;
 
 
     unload (): void;
     unload (): void;
 }
 }

+ 1 - 1
src/interfaces/custom-nodes/ICustomNode.d.ts

@@ -2,7 +2,7 @@ import { TStatement } from '../../types/node/TStatement';
 
 
 import { IInitializable } from '../IInitializable';
 import { IInitializable } from '../IInitializable';
 
 
-export interface ICustomNode extends IInitializable {
+export interface ICustomNode extends IInitializable<any[]> {
     /**
     /**
      * @returns ESTree.Node[]
      * @returns ESTree.Node[]
      */
      */

+ 3 - 3
src/interfaces/custom-nodes/ICustomNodeGroup.d.ts

@@ -1,4 +1,4 @@
-import { TNodeWithBlockScope } from '../../types/node/TNodeWithBlockScope';
+import { TNodeWithStatements } from '../../types/node/TNodeWithStatements';
 
 
 import { ICustomNode } from './ICustomNode';
 import { ICustomNode } from './ICustomNode';
 import { IInitializable } from '../IInitializable';
 import { IInitializable } from '../IInitializable';
@@ -9,10 +9,10 @@ import { ObfuscationEvent } from '../../enums/event-emitters/ObfuscationEvent';
 
 
 export interface ICustomNodeGroup extends IInitializable {
 export interface ICustomNodeGroup extends IInitializable {
     /**
     /**
-     * @param blockScopeNode
+     * @param nodeWithStatements
      * @param stackTraceData
      * @param stackTraceData
      */
      */
-    appendCustomNodes (blockScopeNode: TNodeWithBlockScope, stackTraceData: IStackTraceData[]): void;
+    appendCustomNodes (nodeWithStatements: TNodeWithStatements, stackTraceData: IStackTraceData[]): void;
 
 
     /**
     /**
      * @returns {ObfuscationEvent}
      * @returns {ObfuscationEvent}

+ 5 - 5
src/interfaces/node-transformers/obfuscating-transformers/obfuscating-replacers/IIdentifierObfuscatingReplacer.d.ts

@@ -1,19 +1,19 @@
 import * as ESTree from 'estree';
 import * as ESTree from 'estree';
 
 
-import { TNodeWithBlockScope } from '../../../../types/node/TNodeWithBlockScope';
+import { TNodeWithLexicalScope } from '../../../../types/node/TNodeWithLexicalScope';
 
 
 import { IObfuscatingReplacer } from './IObfuscatingReplacer';
 import { IObfuscatingReplacer } from './IObfuscatingReplacer';
 
 
 export interface IIdentifierObfuscatingReplacer extends IObfuscatingReplacer <ESTree.Identifier> {
 export interface IIdentifierObfuscatingReplacer extends IObfuscatingReplacer <ESTree.Identifier> {
     /**
     /**
      * @param {string} nodeValue
      * @param {string} nodeValue
-     * @param {TNodeWithBlockScope} blockScopeNode
+     * @param {TNodeWithLexicalScope} lexicalScopeNode
      */
      */
-    storeGlobalName (nodeValue: string, blockScopeNode: TNodeWithBlockScope): void;
+    storeGlobalName (nodeValue: string, lexicalScopeNode: TNodeWithLexicalScope): void;
 
 
     /**
     /**
      * @param {string} nodeValue
      * @param {string} nodeValue
-     * @param {TNodeWithBlockScope} blockScopeNode
+     * @param {TNodeWithLexicalScope} lexicalScopeNode
      */
      */
-    storeLocalName (nodeValue: string, blockScopeNode: TNodeWithBlockScope): void;
+    storeLocalName (nodeValue: string, lexicalScopeNode: TNodeWithLexicalScope): void;
 }
 }

+ 3 - 3
src/interfaces/node-transformers/obfuscating-transformers/obfuscating-replacers/IObfuscatingReplacer.d.ts

@@ -1,13 +1,13 @@
 import * as ESTree from 'estree';
 import * as ESTree from 'estree';
 
 
-import { TNodeWithBlockScope } from '../../../../types/node/TNodeWithBlockScope';
+import { TNodeWithLexicalScope } from '../../../../types/node/TNodeWithLexicalScope';
 
 
 export interface IObfuscatingReplacer <T = ESTree.Node> {
 export interface IObfuscatingReplacer <T = ESTree.Node> {
     /**
     /**
      * @param {SimpleLiteral["value"]} nodeValue
      * @param {SimpleLiteral["value"]} nodeValue
-     * @param {TNodeWithBlockScope} blockScopeNode
+     * @param {TNodeWithLexicalScope} lexicalScopeNode
      * @param {number} nodeIdentifier
      * @param {number} nodeIdentifier
      * @returns {T}
      * @returns {T}
      */
      */
-    replace (nodeValue: ESTree.SimpleLiteral['value'], blockScopeNode?: TNodeWithBlockScope, nodeIdentifier?: number): T;
+    replace (nodeValue: ESTree.SimpleLiteral['value'], lexicalScopeNode?: TNodeWithLexicalScope, nodeIdentifier?: number): T;
 }
 }

+ 2 - 2
src/interfaces/IObfuscationResult.d.ts → src/interfaces/source-code/IObfuscatedCode.d.ts

@@ -1,6 +1,6 @@
-import { IInitializable } from './IInitializable';
+import { IInitializable } from '../IInitializable';
 
 
-export interface IObfuscationResult extends IInitializable {
+export interface IObfuscatedCode extends IInitializable <[string, string]> {
     /**
     /**
      * @return {string}
      * @return {string}
      */
      */

+ 5 - 0
src/interfaces/ISourceCode.d.ts → src/interfaces/source-code/ISourceCode.d.ts

@@ -3,4 +3,9 @@ export interface ISourceCode {
      * @returns string
      * @returns string
      */
      */
     getSourceCode (): string;
     getSourceCode (): string;
+
+    /**
+     * @returns string
+     */
+    getSourceMap (): string;
 }
 }

+ 0 - 10
src/interfaces/source-map/ISourceMapCorrector.d.ts

@@ -1,10 +0,0 @@
-import { IObfuscationResult } from '../IObfuscationResult';
-
-export interface ISourceMapCorrector {
-    /**
-     * @param {string} obfuscatedCode
-     * @param {string} sourceMap
-     * @returns {IObfuscationResult}
-     */
-    correct (obfuscatedCode: string, sourceMap: string): IObfuscationResult;
-}

+ 0 - 5
src/interfaces/storages/IArrayStorage.d.ts

@@ -28,11 +28,6 @@ export interface IArrayStorage <V> extends IInitializable {
      */
      */
     getStorageId (): string;
     getStorageId (): string;
 
 
-    /**
-     * @param args
-     */
-    initialize (...args: any[]): void;
-
     /**
     /**
      * @param storage
      * @param storage
      * @param mergeId
      * @param mergeId

+ 0 - 5
src/interfaces/storages/IMapStorage.d.ts

@@ -34,11 +34,6 @@ export interface IMapStorage <K, V> extends IInitializable {
      */
      */
     has (key: K): boolean;
     has (key: K): boolean;
 
 
-    /**
-     * @param args
-     */
-    initialize (...args: any[]): void;
-
     /**
     /**
      * @param storage
      * @param storage
      * @param mergeId
      * @param mergeId

+ 0 - 7
src/interfaces/utils/IRandomGenerator.d.ts

@@ -6,13 +6,6 @@ export interface IRandomGenerator {
      */
      */
     getMathRandom (): number;
     getMathRandom (): number;
 
 
-    /**
-     * @param min
-     * @param max
-     * @returns {number}
-     */
-    getRandomFloat (min: number, max: number): number;
-
     /**
     /**
      * @returns {Chance.Chance}
      * @returns {Chance.Chance}
      */
      */

+ 15 - 11
src/node-transformers/control-flow-transformers/FunctionControlFlowTransformer.ts

@@ -8,7 +8,7 @@ import { TControlFlowCustomNodeFactory } from '../../types/container/custom-node
 import { TControlFlowReplacerFactory } from '../../types/container/node-transformers/TControlFlowReplacerFactory';
 import { TControlFlowReplacerFactory } from '../../types/container/node-transformers/TControlFlowReplacerFactory';
 import { TControlFlowStorage } from '../../types/storages/TControlFlowStorage';
 import { TControlFlowStorage } from '../../types/storages/TControlFlowStorage';
 import { TControlFlowStorageFactory } from '../../types/container/node-transformers/TControlFlowStorageFactory';
 import { TControlFlowStorageFactory } from '../../types/container/node-transformers/TControlFlowStorageFactory';
-import { TNodeWithBlockScope } from '../../types/node/TNodeWithBlockScope';
+import { TNodeWithStatements } from '../../types/node/TNodeWithStatements';
 
 
 import { ICustomNode } from '../../interfaces/custom-nodes/ICustomNode';
 import { ICustomNode } from '../../interfaces/custom-nodes/ICustomNode';
 import { IOptions } from '../../interfaces/options/IOptions';
 import { IOptions } from '../../interfaces/options/IOptions';
@@ -24,7 +24,7 @@ import { AbstractNodeTransformer } from '../AbstractNodeTransformer';
 import { NodeAppender } from '../../node/NodeAppender';
 import { NodeAppender } from '../../node/NodeAppender';
 import { NodeGuards } from '../../node/NodeGuards';
 import { NodeGuards } from '../../node/NodeGuards';
 import { NodeMetadata } from '../../node/NodeMetadata';
 import { NodeMetadata } from '../../node/NodeMetadata';
-import { NodeUtils } from '../../node/NodeUtils';
+import { NodeStatementUtils } from '../../node/NodeStatementUtils';
 
 
 @injectable()
 @injectable()
 export class FunctionControlFlowTransformer extends AbstractNodeTransformer {
 export class FunctionControlFlowTransformer extends AbstractNodeTransformer {
@@ -59,9 +59,9 @@ export class FunctionControlFlowTransformer extends AbstractNodeTransformer {
     private readonly visitedFunctionNodes: Set<ESTree.Function> = new Set();
     private readonly visitedFunctionNodes: Set<ESTree.Function> = new Set();
 
 
     /**
     /**
-     * @type {Set<TNodeWithBlockScope>}
+     * @type {Set<TNodeWithStatements>}
      */
      */
-    private readonly hostNodesWithControlFlowNode: Set<TNodeWithBlockScope> = new Set();
+    private readonly hostNodesWithControlFlowNode: Set<TNodeWithStatements> = new Set();
 
 
     /**
     /**
      * @type {TControlFlowReplacerFactory}
      * @type {TControlFlowReplacerFactory}
@@ -140,7 +140,7 @@ export class FunctionControlFlowTransformer extends AbstractNodeTransformer {
             return functionNode;
             return functionNode;
         }
         }
 
 
-        const hostNode: TNodeWithBlockScope = this.getHostNode(functionNode.body);
+        const hostNode: TNodeWithStatements = this.getHostNode(functionNode.body);
         const controlFlowStorage: TControlFlowStorage = this.getControlFlowStorage(hostNode);
         const controlFlowStorage: TControlFlowStorage = this.getControlFlowStorage(hostNode);
 
 
         this.controlFlowData.set(hostNode, controlFlowStorage);
         this.controlFlowData.set(hostNode, controlFlowStorage);
@@ -162,15 +162,19 @@ export class FunctionControlFlowTransformer extends AbstractNodeTransformer {
     }
     }
 
 
     /**
     /**
-     * @param {TNodeWithBlockScope} hostNode
+     * @param {TNodeWithStatements} hostNode
      * @returns {TControlFlowStorage}
      * @returns {TControlFlowStorage}
      */
      */
-    private getControlFlowStorage (hostNode: TNodeWithBlockScope): TControlFlowStorage {
+    private getControlFlowStorage (hostNode: TNodeWithStatements): TControlFlowStorage {
         const controlFlowStorage: TControlFlowStorage = this.controlFlowStorageFactory();
         const controlFlowStorage: TControlFlowStorage = this.controlFlowStorageFactory();
 
 
         if (this.controlFlowData.has(hostNode)) {
         if (this.controlFlowData.has(hostNode)) {
             if (this.hostNodesWithControlFlowNode.has(hostNode)) {
             if (this.hostNodesWithControlFlowNode.has(hostNode)) {
-                hostNode.body.shift();
+                if (NodeGuards.isSwitchCaseNode(hostNode)) {
+                    hostNode.consequent.shift();
+                } else {
+                    hostNode.body.shift();
+                }
             }
             }
 
 
             const hostControlFlowStorage: TControlFlowStorage = <TControlFlowStorage>this.controlFlowData.get(hostNode);
             const hostControlFlowStorage: TControlFlowStorage = <TControlFlowStorage>this.controlFlowData.get(hostNode);
@@ -183,10 +187,10 @@ export class FunctionControlFlowTransformer extends AbstractNodeTransformer {
 
 
     /**
     /**
      * @param {BlockStatement} functionNodeBody
      * @param {BlockStatement} functionNodeBody
-     * @returns {TNodeWithBlockScope}
+     * @returns {TNodeWithStatements}
      */
      */
-    private getHostNode (functionNodeBody: ESTree.BlockStatement): TNodeWithBlockScope {
-        const blockScopesOfNode: TNodeWithBlockScope[] = NodeUtils.getBlockScopesOfNode(functionNodeBody);
+    private getHostNode (functionNodeBody: ESTree.BlockStatement): TNodeWithStatements {
+        const blockScopesOfNode: TNodeWithStatements[] = NodeStatementUtils.getParentNodesWithStatements(functionNodeBody);
 
 
         if (blockScopesOfNode.length === 1) {
         if (blockScopesOfNode.length === 1) {
             return functionNodeBody;
             return functionNodeBody;

+ 18 - 15
src/node-transformers/converting-transformers/properties-extractors/AbstractPropertiesExtractor.ts

@@ -3,7 +3,7 @@ import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers';
 
 
 import * as ESTree from 'estree';
 import * as ESTree from 'estree';
 
 
-import { TNodeWithScope } from '../../../types/node/TNodeWithScope';
+import { TNodeWithStatements } from '../../../types/node/TNodeWithStatements';
 
 
 import { IOptions } from '../../../interfaces/options/IOptions';
 import { IOptions } from '../../../interfaces/options/IOptions';
 import { IPropertiesExtractor } from '../../../interfaces/node-transformers/converting-transformers/properties-extractors/IPropertiesExtractor';
 import { IPropertiesExtractor } from '../../../interfaces/node-transformers/converting-transformers/properties-extractors/IPropertiesExtractor';
@@ -12,14 +12,14 @@ import { IRandomGenerator } from '../../../interfaces/utils/IRandomGenerator';
 import { NodeAppender } from '../../../node/NodeAppender';
 import { NodeAppender } from '../../../node/NodeAppender';
 import { NodeFactory } from '../../../node/NodeFactory';
 import { NodeFactory } from '../../../node/NodeFactory';
 import { NodeGuards } from '../../../node/NodeGuards';
 import { NodeGuards } from '../../../node/NodeGuards';
-import { NodeUtils } from '../../../node/NodeUtils';
+import { NodeStatementUtils } from '../../../node/NodeStatementUtils';
 
 
 @injectable()
 @injectable()
 export abstract class AbstractPropertiesExtractor implements IPropertiesExtractor {
 export abstract class AbstractPropertiesExtractor implements IPropertiesExtractor {
     /**
     /**
-     * @type {Map<ESTree.ObjectExpression, TNodeWithScope>}
+     * @type {Map<ESTree.ObjectExpression, TNodeWithStatements>}
      */
      */
-    protected readonly cachedHostScopesMap: Map <ESTree.ObjectExpression, TNodeWithScope> = new Map();
+    protected readonly cachedHostNodesWithStatementsMap: Map <ESTree.ObjectExpression, TNodeWithStatements> = new Map();
 
 
     /**
     /**
      * @type {Map<ESTree.ObjectExpression, ESTree.Statement>}
      * @type {Map<ESTree.ObjectExpression, ESTree.Statement>}
@@ -179,10 +179,13 @@ export abstract class AbstractPropertiesExtractor implements IPropertiesExtracto
             .extractPropertiesToExpressionStatements(properties, memberExpressionHostNode);
             .extractPropertiesToExpressionStatements(properties, memberExpressionHostNode);
 
 
         const hostStatement: ESTree.Statement = this.getHostStatement(objectExpressionNode);
         const hostStatement: ESTree.Statement = this.getHostStatement(objectExpressionNode);
-        const scopeNode: TNodeWithScope = this.getHostScopeNode(objectExpressionNode, hostStatement);
+        const hostNodeWithStatements: TNodeWithStatements = this.getHostNodeWithStatements(
+            objectExpressionNode,
+            hostStatement
+        );
 
 
         this.filterExtractedObjectExpressionProperties(objectExpressionNode, removablePropertyIds);
         this.filterExtractedObjectExpressionProperties(objectExpressionNode, removablePropertyIds);
-        NodeAppender.insertAfter(scopeNode, expressionStatements, hostStatement);
+        NodeAppender.insertAfter(hostNodeWithStatements, expressionStatements, hostStatement);
 
 
         return objectExpressionNode;
         return objectExpressionNode;
     }
     }
@@ -190,21 +193,21 @@ export abstract class AbstractPropertiesExtractor implements IPropertiesExtracto
     /**
     /**
      * @param {ObjectExpression} objectExpressionNode
      * @param {ObjectExpression} objectExpressionNode
      * @param {Statement} hostStatement
      * @param {Statement} hostStatement
-     * @returns {TNodeWithScope}
+     * @returns {TNodeWithStatements}
      */
      */
-    protected getHostScopeNode (
+    protected getHostNodeWithStatements (
         objectExpressionNode: ESTree.ObjectExpression,
         objectExpressionNode: ESTree.ObjectExpression,
         hostStatement: ESTree.Statement
         hostStatement: ESTree.Statement
-    ): TNodeWithScope {
-        if (this.cachedHostScopesMap.has(objectExpressionNode)) {
-            return <TNodeWithScope>this.cachedHostScopesMap.get(objectExpressionNode);
+    ): TNodeWithStatements {
+        if (this.cachedHostNodesWithStatementsMap.has(objectExpressionNode)) {
+            return <TNodeWithStatements>this.cachedHostNodesWithStatementsMap.get(objectExpressionNode);
         }
         }
 
 
-        const scopeNode: TNodeWithScope = NodeUtils.getScopeOfNode(hostStatement);
+        const nodeWithStatements: TNodeWithStatements = NodeStatementUtils.getScopeOfNode(hostStatement);
 
 
-        this.cachedHostScopesMap.set(objectExpressionNode, scopeNode);
+        this.cachedHostNodesWithStatementsMap.set(objectExpressionNode, nodeWithStatements);
 
 
-        return scopeNode;
+        return nodeWithStatements;
     }
     }
 
 
     /**
     /**
@@ -218,7 +221,7 @@ export abstract class AbstractPropertiesExtractor implements IPropertiesExtracto
             return <ESTree.Statement>this.cachedHostStatementsMap.get(objectExpressionNode);
             return <ESTree.Statement>this.cachedHostStatementsMap.get(objectExpressionNode);
         }
         }
 
 
-        const hostStatement: ESTree.Statement = NodeUtils.getRootStatementOfNode(objectExpressionNode);
+        const hostStatement: ESTree.Statement = NodeStatementUtils.getRootStatementOfNode(objectExpressionNode);
 
 
         this.cachedHostStatementsMap.set(objectExpressionNode, hostStatement);
         this.cachedHostStatementsMap.set(objectExpressionNode, hostStatement);
 
 

+ 19 - 12
src/node-transformers/dead-code-injection-transformers/DeadCodeInjectionTransformer.ts

@@ -5,8 +5,7 @@ import * as estraverse from 'estraverse';
 import * as ESTree from 'estree';
 import * as ESTree from 'estree';
 
 
 import { TDeadNodeInjectionCustomNodeFactory } from '../../types/container/custom-nodes/TDeadNodeInjectionCustomNodeFactory';
 import { TDeadNodeInjectionCustomNodeFactory } from '../../types/container/custom-nodes/TDeadNodeInjectionCustomNodeFactory';
-import { TNodeWithBlockScope } from '../../types/node/TNodeWithBlockScope';
-import { TNodeWithScope } from '../../types/node/TNodeWithScope';
+import { TNodeWithStatements } from '../../types/node/TNodeWithStatements';
 
 
 import { ICustomNode } from '../../interfaces/custom-nodes/ICustomNode';
 import { ICustomNode } from '../../interfaces/custom-nodes/ICustomNode';
 import { IOptions } from '../../interfaces/options/IOptions';
 import { IOptions } from '../../interfaces/options/IOptions';
@@ -22,6 +21,7 @@ import { TransformationStage } from '../../enums/node-transformers/Transformatio
 import { AbstractNodeTransformer } from '../AbstractNodeTransformer';
 import { AbstractNodeTransformer } from '../AbstractNodeTransformer';
 import { NodeFactory } from '../../node/NodeFactory';
 import { NodeFactory } from '../../node/NodeFactory';
 import { NodeGuards } from '../../node/NodeGuards';
 import { NodeGuards } from '../../node/NodeGuards';
+import { NodeStatementUtils } from '../../node/NodeStatementUtils';
 import { NodeUtils } from '../../node/NodeUtils';
 import { NodeUtils } from '../../node/NodeUtils';
 
 
 @injectable()
 @injectable()
@@ -117,7 +117,7 @@ export class DeadCodeInjectionTransformer extends AbstractNodeTransformer {
             return false;
             return false;
         }
         }
 
 
-        const scopeNode: TNodeWithScope = NodeUtils.getScopeOfNode(targetNode);
+        const scopeNode: TNodeWithStatements = NodeStatementUtils.getScopeOfNode(targetNode);
         const scopeBody: ESTree.Statement[] = !NodeGuards.isSwitchCaseNode(scopeNode)
         const scopeBody: ESTree.Statement[] = !NodeGuards.isSwitchCaseNode(scopeNode)
             ? <ESTree.Statement[]>scopeNode.body
             ? <ESTree.Statement[]>scopeNode.body
             : scopeNode.consequent;
             : scopeNode.consequent;
@@ -204,10 +204,10 @@ export class DeadCodeInjectionTransformer extends AbstractNodeTransformer {
             return false;
             return false;
         }
         }
 
 
-        const blockScopeOfBlockStatementNode: TNodeWithBlockScope = NodeUtils
-            .getBlockScopeOfNode(blockStatementNode);
+        const parentNodeWithStatements: TNodeWithStatements = NodeStatementUtils
+            .getParentNodeWithStatements(blockStatementNode);
 
 
-        return blockScopeOfBlockStatementNode.type !== NodeType.Program;
+        return parentNodeWithStatements.type !== NodeType.Program;
     }
     }
 
 
     /**
     /**
@@ -261,7 +261,7 @@ export class DeadCodeInjectionTransformer extends AbstractNodeTransformer {
                     return;
                     return;
                 }
                 }
 
 
-                let clonedBlockStatementNode: ESTree.BlockStatement = NodeUtils.clone(node);
+                const clonedBlockStatementNode: ESTree.BlockStatement = NodeUtils.clone(node);
 
 
                 if (!DeadCodeInjectionTransformer.isValidCollectedBlockStatementNode(clonedBlockStatementNode)) {
                 if (!DeadCodeInjectionTransformer.isValidCollectedBlockStatementNode(clonedBlockStatementNode)) {
                     return;
                     return;
@@ -270,10 +270,10 @@ export class DeadCodeInjectionTransformer extends AbstractNodeTransformer {
                 /**
                 /**
                  * We should transform identifiers in the dead code block statement to avoid conflicts with original code
                  * We should transform identifiers in the dead code block statement to avoid conflicts with original code
                  */
                  */
-                NodeUtils.parentizeNode(clonedBlockStatementNode, clonedBlockStatementNode);
-                clonedBlockStatementNode = this.makeClonedBlockStatementNodeUnique(clonedBlockStatementNode);
+                const transformedBlockStatementNode: ESTree.BlockStatement =
+                    this.makeClonedBlockStatementNodeUnique(clonedBlockStatementNode);
 
 
-                this.collectedBlockStatements.push(clonedBlockStatementNode);
+                this.collectedBlockStatements.push(transformedBlockStatementNode);
             }
             }
         });
         });
 
 
@@ -346,11 +346,18 @@ export class DeadCodeInjectionTransformer extends AbstractNodeTransformer {
      * @returns {BlockStatement}
      * @returns {BlockStatement}
      */
      */
     private makeClonedBlockStatementNodeUnique (clonedBlockStatementNode: ESTree.BlockStatement): ESTree.BlockStatement {
     private makeClonedBlockStatementNodeUnique (clonedBlockStatementNode: ESTree.BlockStatement): ESTree.BlockStatement {
+        // should wrap cloned block statement node into function node for correct scope encapsulation
+        const hostNode: ESTree.FunctionExpression = NodeFactory
+            .functionExpressionNode([], clonedBlockStatementNode);
+
+        NodeUtils.parentizeNode(hostNode, hostNode);
+        NodeUtils.parentizeNode(clonedBlockStatementNode, hostNode);
+
         return this.transformersRunner.transform(
         return this.transformersRunner.transform(
-            clonedBlockStatementNode,
+            hostNode,
             DeadCodeInjectionTransformer.transformersToRenameBlockScopeIdentifiers,
             DeadCodeInjectionTransformer.transformersToRenameBlockScopeIdentifiers,
             TransformationStage.Obfuscating
             TransformationStage.Obfuscating
-        );
+        ).body;
     }
     }
 
 
     /**
     /**

+ 15 - 11
src/node-transformers/obfuscating-transformers/CatchClauseTransformer.ts

@@ -5,7 +5,7 @@ import * as estraverse from 'estraverse';
 import * as ESTree from 'estree';
 import * as ESTree from 'estree';
 
 
 import { TIdentifierObfuscatingReplacerFactory } from '../../types/container/node-transformers/TIdentifierObfuscatingReplacerFactory';
 import { TIdentifierObfuscatingReplacerFactory } from '../../types/container/node-transformers/TIdentifierObfuscatingReplacerFactory';
-import { TNodeWithBlockScope } from '../../types/node/TNodeWithBlockScope';
+import { TNodeWithLexicalScope } from '../../types/node/TNodeWithLexicalScope';
 
 
 import { IIdentifierObfuscatingReplacer } from '../../interfaces/node-transformers/obfuscating-transformers/obfuscating-replacers/IIdentifierObfuscatingReplacer';
 import { IIdentifierObfuscatingReplacer } from '../../interfaces/node-transformers/obfuscating-transformers/obfuscating-replacers/IIdentifierObfuscatingReplacer';
 import { IOptions } from '../../interfaces/options/IOptions';
 import { IOptions } from '../../interfaces/options/IOptions';
@@ -17,8 +17,8 @@ import { TransformationStage } from '../../enums/node-transformers/Transformatio
 
 
 import { AbstractNodeTransformer } from '../AbstractNodeTransformer';
 import { AbstractNodeTransformer } from '../AbstractNodeTransformer';
 import { NodeGuards } from '../../node/NodeGuards';
 import { NodeGuards } from '../../node/NodeGuards';
+import { NodeLexicalScopeUtils } from '../../node/NodeLexicalScopeUtils';
 import { NodeMetadata } from '../../node/NodeMetadata';
 import { NodeMetadata } from '../../node/NodeMetadata';
-import { NodeUtils } from '../../node/NodeUtils';
 
 
 /**
 /**
  * replaces:
  * replaces:
@@ -79,40 +79,44 @@ export class CatchClauseTransformer extends AbstractNodeTransformer {
      * @returns {NodeGuards}
      * @returns {NodeGuards}
      */
      */
     public transformNode (catchClauseNode: ESTree.CatchClause, parentNode: ESTree.Node): ESTree.Node {
     public transformNode (catchClauseNode: ESTree.CatchClause, parentNode: ESTree.Node): ESTree.Node {
-        const blockScopeNode: TNodeWithBlockScope = NodeUtils.getBlockScopeOfNode(catchClauseNode);
+        const lexicalScopeNode: TNodeWithLexicalScope | undefined = NodeLexicalScopeUtils.getLexicalScope(catchClauseNode);
 
 
-        this.storeCatchClauseParam(catchClauseNode, blockScopeNode);
-        this.replaceCatchClauseParam(catchClauseNode, blockScopeNode);
+        if (!lexicalScopeNode) {
+            return catchClauseNode;
+        }
+
+        this.storeCatchClauseParam(catchClauseNode, lexicalScopeNode);
+        this.replaceCatchClauseParam(catchClauseNode, lexicalScopeNode);
 
 
         return catchClauseNode;
         return catchClauseNode;
     }
     }
 
 
     /**
     /**
      * @param {CatchClause} catchClauseNode
      * @param {CatchClause} catchClauseNode
-     * @param {TNodeWithBlockScope} blockScopeNode
+     * @param {TNodeWithLexicalScope} lexicalScopeNode
      */
      */
     private storeCatchClauseParam (
     private storeCatchClauseParam (
         catchClauseNode: ESTree.CatchClause,
         catchClauseNode: ESTree.CatchClause,
-        blockScopeNode: TNodeWithBlockScope
+        lexicalScopeNode: TNodeWithLexicalScope
     ): void {
     ): void {
         if (NodeGuards.isIdentifierNode(catchClauseNode.param)) {
         if (NodeGuards.isIdentifierNode(catchClauseNode.param)) {
-            this.identifierObfuscatingReplacer.storeLocalName(catchClauseNode.param.name, blockScopeNode);
+            this.identifierObfuscatingReplacer.storeLocalName(catchClauseNode.param.name, lexicalScopeNode);
         }
         }
     }
     }
 
 
     /**
     /**
      * @param {CatchClause} catchClauseNode
      * @param {CatchClause} catchClauseNode
-     * @param {TNodeWithBlockScope} blockScopeNode
+     * @param {TNodeWithLexicalScope} lexicalScopeNode
      */
      */
     private replaceCatchClauseParam (
     private replaceCatchClauseParam (
         catchClauseNode: ESTree.CatchClause,
         catchClauseNode: ESTree.CatchClause,
-        blockScopeNode: TNodeWithBlockScope
+        lexicalScopeNode: TNodeWithLexicalScope
     ): void {
     ): void {
         estraverse.replace(catchClauseNode, {
         estraverse.replace(catchClauseNode, {
             enter: (node: ESTree.Node, parentNode: ESTree.Node | null): void => {
             enter: (node: ESTree.Node, parentNode: ESTree.Node | null): void => {
                 if (parentNode && NodeGuards.isReplaceableIdentifierNode(node, parentNode)) {
                 if (parentNode && NodeGuards.isReplaceableIdentifierNode(node, parentNode)) {
                     const newIdentifier: ESTree.Identifier = this.identifierObfuscatingReplacer
                     const newIdentifier: ESTree.Identifier = this.identifierObfuscatingReplacer
-                        .replace(node.name, blockScopeNode);
+                        .replace(node.name, lexicalScopeNode);
                     const newIdentifierName: string = newIdentifier.name;
                     const newIdentifierName: string = newIdentifier.name;
 
 
                     if (node.name !== newIdentifierName) {
                     if (node.name !== newIdentifierName) {

+ 26 - 21
src/node-transformers/obfuscating-transformers/ClassDeclarationTransformer.ts

@@ -5,7 +5,7 @@ import * as estraverse from 'estraverse';
 import * as ESTree from 'estree';
 import * as ESTree from 'estree';
 
 
 import { TIdentifierObfuscatingReplacerFactory } from "../../types/container/node-transformers/TIdentifierObfuscatingReplacerFactory";
 import { TIdentifierObfuscatingReplacerFactory } from "../../types/container/node-transformers/TIdentifierObfuscatingReplacerFactory";
-import { TNodeWithBlockScope } from '../../types/node/TNodeWithBlockScope';
+import { TNodeWithLexicalScope } from '../../types/node/TNodeWithLexicalScope';
 import { TReplaceableIdentifiers } from '../../types/node-transformers/TReplaceableIdentifiers';
 import { TReplaceableIdentifiers } from '../../types/node-transformers/TReplaceableIdentifiers';
 import { TReplaceableIdentifiersNames } from '../../types/node-transformers/TReplaceableIdentifiersNames';
 import { TReplaceableIdentifiersNames } from '../../types/node-transformers/TReplaceableIdentifiersNames';
 
 
@@ -20,8 +20,8 @@ import { TransformationStage } from '../../enums/node-transformers/Transformatio
 
 
 import { AbstractNodeTransformer } from '../AbstractNodeTransformer';
 import { AbstractNodeTransformer } from '../AbstractNodeTransformer';
 import { NodeGuards } from '../../node/NodeGuards';
 import { NodeGuards } from '../../node/NodeGuards';
+import { NodeLexicalScopeUtils } from '../../node/NodeLexicalScopeUtils';
 import { NodeMetadata } from '../../node/NodeMetadata';
 import { NodeMetadata } from '../../node/NodeMetadata';
-import { NodeUtils } from '../../node/NodeUtils';
 
 
 /**
 /**
  * replaces:
  * replaces:
@@ -92,20 +92,25 @@ export class ClassDeclarationTransformer extends AbstractNodeTransformer {
      * @returns {NodeGuards}
      * @returns {NodeGuards}
      */
      */
     public transformNode (classDeclarationNode: ESTree.ClassDeclaration, parentNode: ESTree.Node): ESTree.Node {
     public transformNode (classDeclarationNode: ESTree.ClassDeclaration, parentNode: ESTree.Node): ESTree.Node {
-        const blockScopeNode: TNodeWithBlockScope = NodeUtils.getBlockScopeOfNode(classDeclarationNode);
-        const isGlobalDeclaration: boolean = blockScopeNode.type === NodeType.Program;
+        const lexicalScopeNode: TNodeWithLexicalScope | undefined = NodeLexicalScopeUtils.getLexicalScope(classDeclarationNode);
+
+        if (!lexicalScopeNode) {
+            return classDeclarationNode;
+        }
+
+        const isGlobalDeclaration: boolean = lexicalScopeNode.type === NodeType.Program;
 
 
         if (!this.options.renameGlobals && isGlobalDeclaration) {
         if (!this.options.renameGlobals && isGlobalDeclaration) {
             return classDeclarationNode;
             return classDeclarationNode;
         }
         }
 
 
-        this.storeClassName(classDeclarationNode, blockScopeNode, isGlobalDeclaration);
+        this.storeClassName(classDeclarationNode, lexicalScopeNode, isGlobalDeclaration);
 
 
         // check for cached identifiers for current scope node. If exist - loop through them.
         // check for cached identifiers for current scope node. If exist - loop through them.
-        if (this.replaceableIdentifiers.has(blockScopeNode)) {
-            this.replaceScopeCachedIdentifiers(classDeclarationNode, blockScopeNode);
+        if (this.replaceableIdentifiers.has(lexicalScopeNode)) {
+            this.replaceScopeCachedIdentifiers(classDeclarationNode, lexicalScopeNode);
         } else {
         } else {
-            this.replaceScopeIdentifiers(blockScopeNode);
+            this.replaceScopeIdentifiers(lexicalScopeNode);
         }
         }
 
 
         return classDeclarationNode;
         return classDeclarationNode;
@@ -113,31 +118,31 @@ export class ClassDeclarationTransformer extends AbstractNodeTransformer {
 
 
     /**
     /**
      * @param {ClassDeclaration} classDeclarationNode
      * @param {ClassDeclaration} classDeclarationNode
-     * @param {TNodeWithBlockScope} blockScopeNode
+     * @param {TNodeWithLexicalScope} lexicalScopeNode
      * @param {boolean} isGlobalDeclaration
      * @param {boolean} isGlobalDeclaration
      */
      */
     private storeClassName (
     private storeClassName (
         classDeclarationNode: ESTree.ClassDeclaration,
         classDeclarationNode: ESTree.ClassDeclaration,
-        blockScopeNode: TNodeWithBlockScope,
+        lexicalScopeNode: TNodeWithLexicalScope,
         isGlobalDeclaration: boolean
         isGlobalDeclaration: boolean
     ): void {
     ): void {
         if (isGlobalDeclaration) {
         if (isGlobalDeclaration) {
-            this.identifierObfuscatingReplacer.storeGlobalName(classDeclarationNode.id.name, blockScopeNode);
+            this.identifierObfuscatingReplacer.storeGlobalName(classDeclarationNode.id.name, lexicalScopeNode);
         } else {
         } else {
-            this.identifierObfuscatingReplacer.storeLocalName(classDeclarationNode.id.name, blockScopeNode);
+            this.identifierObfuscatingReplacer.storeLocalName(classDeclarationNode.id.name, lexicalScopeNode);
         }
         }
     }
     }
 
 
     /**
     /**
      * @param {ClassDeclaration} classDeclarationNode
      * @param {ClassDeclaration} classDeclarationNode
-     * @param {TNodeWithBlockScope} blockScopeNode
+     * @param {TNodeWithLexicalScope} lexicalScopeNode
      */
      */
     private replaceScopeCachedIdentifiers (
     private replaceScopeCachedIdentifiers (
         classDeclarationNode: ESTree.ClassDeclaration,
         classDeclarationNode: ESTree.ClassDeclaration,
-        blockScopeNode: TNodeWithBlockScope
+        lexicalScopeNode: TNodeWithLexicalScope
     ): void {
     ): void {
         const cachedReplaceableIdentifiersNamesMap: TReplaceableIdentifiersNames =
         const cachedReplaceableIdentifiersNamesMap: TReplaceableIdentifiersNames =
-            <TReplaceableIdentifiersNames>this.replaceableIdentifiers.get(blockScopeNode);
+            <TReplaceableIdentifiersNames>this.replaceableIdentifiers.get(lexicalScopeNode);
 
 
         const cachedReplaceableIdentifiers: ESTree.Identifier[] | undefined = cachedReplaceableIdentifiersNamesMap
         const cachedReplaceableIdentifiers: ESTree.Identifier[] | undefined = cachedReplaceableIdentifiersNamesMap
             .get(classDeclarationNode.id.name);
             .get(classDeclarationNode.id.name);
@@ -151,7 +156,7 @@ export class ClassDeclarationTransformer extends AbstractNodeTransformer {
         for (let i: number = 0; i < cachedReplaceableIdentifierLength; i++) {
         for (let i: number = 0; i < cachedReplaceableIdentifierLength; i++) {
             const replaceableIdentifier: ESTree.Identifier = cachedReplaceableIdentifiers[i];
             const replaceableIdentifier: ESTree.Identifier = cachedReplaceableIdentifiers[i];
             const newReplaceableIdentifier: ESTree.Identifier = this.identifierObfuscatingReplacer
             const newReplaceableIdentifier: ESTree.Identifier = this.identifierObfuscatingReplacer
-                .replace(replaceableIdentifier.name, blockScopeNode);
+                .replace(replaceableIdentifier.name, lexicalScopeNode);
 
 
             replaceableIdentifier.name = newReplaceableIdentifier.name;
             replaceableIdentifier.name = newReplaceableIdentifier.name;
             NodeMetadata.set(replaceableIdentifier, { renamedIdentifier: true });
             NodeMetadata.set(replaceableIdentifier, { renamedIdentifier: true });
@@ -159,12 +164,12 @@ export class ClassDeclarationTransformer extends AbstractNodeTransformer {
     }
     }
 
 
     /**
     /**
-     * @param {TNodeWithBlockScope} blockScopeNode
+     * @param {TNodeWithLexicalScope} lexicalScopeNode
      */
      */
-    private replaceScopeIdentifiers (blockScopeNode: TNodeWithBlockScope): void {
+    private replaceScopeIdentifiers (lexicalScopeNode: TNodeWithLexicalScope): void {
         const storedReplaceableIdentifiersNamesMap: TReplaceableIdentifiersNames = new Map();
         const storedReplaceableIdentifiersNamesMap: TReplaceableIdentifiersNames = new Map();
 
 
-        estraverse.replace(blockScopeNode, {
+        estraverse.replace(lexicalScopeNode, {
             enter: (node: ESTree.Node, parentNode: ESTree.Node | null): void => {
             enter: (node: ESTree.Node, parentNode: ESTree.Node | null): void => {
                 if (
                 if (
                     parentNode
                     parentNode
@@ -172,7 +177,7 @@ export class ClassDeclarationTransformer extends AbstractNodeTransformer {
                     && !NodeMetadata.isRenamedIdentifier(node)
                     && !NodeMetadata.isRenamedIdentifier(node)
                 ) {
                 ) {
                     const newIdentifier: ESTree.Identifier = this.identifierObfuscatingReplacer
                     const newIdentifier: ESTree.Identifier = this.identifierObfuscatingReplacer
-                        .replace(node.name, blockScopeNode);
+                        .replace(node.name, lexicalScopeNode);
                     const newIdentifierName: string = newIdentifier.name;
                     const newIdentifierName: string = newIdentifier.name;
 
 
                     if (node.name !== newIdentifierName) {
                     if (node.name !== newIdentifierName) {
@@ -189,6 +194,6 @@ export class ClassDeclarationTransformer extends AbstractNodeTransformer {
             }
             }
         });
         });
 
 
-        this.replaceableIdentifiers.set(blockScopeNode, storedReplaceableIdentifiersNamesMap);
+        this.replaceableIdentifiers.set(lexicalScopeNode, storedReplaceableIdentifiersNamesMap);
     }
     }
 }
 }

+ 26 - 21
src/node-transformers/obfuscating-transformers/FunctionDeclarationTransformer.ts

@@ -5,7 +5,7 @@ import * as estraverse from 'estraverse';
 import * as ESTree from 'estree';
 import * as ESTree from 'estree';
 
 
 import { TIdentifierObfuscatingReplacerFactory } from "../../types/container/node-transformers/TIdentifierObfuscatingReplacerFactory";
 import { TIdentifierObfuscatingReplacerFactory } from "../../types/container/node-transformers/TIdentifierObfuscatingReplacerFactory";
-import { TNodeWithBlockScope } from '../../types/node/TNodeWithBlockScope';
+import { TNodeWithLexicalScope } from '../../types/node/TNodeWithLexicalScope';
 import { TReplaceableIdentifiers } from '../../types/node-transformers/TReplaceableIdentifiers';
 import { TReplaceableIdentifiers } from '../../types/node-transformers/TReplaceableIdentifiers';
 import { TReplaceableIdentifiersNames } from '../../types/node-transformers/TReplaceableIdentifiersNames';
 import { TReplaceableIdentifiersNames } from '../../types/node-transformers/TReplaceableIdentifiersNames';
 
 
@@ -20,8 +20,8 @@ import { TransformationStage } from '../../enums/node-transformers/Transformatio
 
 
 import { AbstractNodeTransformer } from '../AbstractNodeTransformer';
 import { AbstractNodeTransformer } from '../AbstractNodeTransformer';
 import { NodeGuards } from '../../node/NodeGuards';
 import { NodeGuards } from '../../node/NodeGuards';
+import { NodeLexicalScopeUtils } from '../../node/NodeLexicalScopeUtils';
 import { NodeMetadata } from '../../node/NodeMetadata';
 import { NodeMetadata } from '../../node/NodeMetadata';
-import { NodeUtils } from '../../node/NodeUtils';
 
 
 /**
 /**
  * replaces:
  * replaces:
@@ -92,20 +92,25 @@ export class FunctionDeclarationTransformer extends AbstractNodeTransformer {
      * @returns {NodeGuards}
      * @returns {NodeGuards}
      */
      */
     public transformNode (functionDeclarationNode: ESTree.FunctionDeclaration, parentNode: ESTree.Node): ESTree.Node {
     public transformNode (functionDeclarationNode: ESTree.FunctionDeclaration, parentNode: ESTree.Node): ESTree.Node {
-        const blockScopeNode: TNodeWithBlockScope = NodeUtils.getBlockScopeOfNode(functionDeclarationNode);
-        const isGlobalDeclaration: boolean = blockScopeNode.type === NodeType.Program;
+        const lexicalScopeNode: TNodeWithLexicalScope | undefined = NodeLexicalScopeUtils.getLexicalScope(parentNode);
+
+        if (!lexicalScopeNode) {
+            return functionDeclarationNode;
+        }
+
+        const isGlobalDeclaration: boolean = lexicalScopeNode.type === NodeType.Program;
 
 
         if (!this.options.renameGlobals && isGlobalDeclaration) {
         if (!this.options.renameGlobals && isGlobalDeclaration) {
             return functionDeclarationNode;
             return functionDeclarationNode;
         }
         }
 
 
-        this.storeFunctionName(functionDeclarationNode, blockScopeNode, isGlobalDeclaration);
+        this.storeFunctionName(functionDeclarationNode, lexicalScopeNode, isGlobalDeclaration);
 
 
         // check for cached identifiers for current scope node. If exist - loop through them.
         // check for cached identifiers for current scope node. If exist - loop through them.
-        if (this.replaceableIdentifiers.has(blockScopeNode)) {
-            this.replaceScopeCachedIdentifiers(functionDeclarationNode, blockScopeNode);
+        if (this.replaceableIdentifiers.has(lexicalScopeNode)) {
+            this.replaceScopeCachedIdentifiers(functionDeclarationNode, lexicalScopeNode);
         } else {
         } else {
-            this.replaceScopeIdentifiers(blockScopeNode);
+            this.replaceScopeIdentifiers(lexicalScopeNode);
         }
         }
 
 
         return functionDeclarationNode;
         return functionDeclarationNode;
@@ -113,31 +118,31 @@ export class FunctionDeclarationTransformer extends AbstractNodeTransformer {
 
 
     /**
     /**
      * @param {FunctionDeclaration} functionDeclarationNode
      * @param {FunctionDeclaration} functionDeclarationNode
-     * @param {TNodeWithBlockScope} blockScopeNode
+     * @param {TNodeWithLexicalScope} lexicalScopeNode
      * @param {boolean} isGlobalDeclaration
      * @param {boolean} isGlobalDeclaration
      */
      */
     private storeFunctionName (
     private storeFunctionName (
         functionDeclarationNode: ESTree.FunctionDeclaration,
         functionDeclarationNode: ESTree.FunctionDeclaration,
-        blockScopeNode: TNodeWithBlockScope,
+        lexicalScopeNode: TNodeWithLexicalScope,
         isGlobalDeclaration: boolean
         isGlobalDeclaration: boolean
     ): void {
     ): void {
         if (isGlobalDeclaration) {
         if (isGlobalDeclaration) {
-            this.identifierObfuscatingReplacer.storeGlobalName(functionDeclarationNode.id.name, blockScopeNode);
+            this.identifierObfuscatingReplacer.storeGlobalName(functionDeclarationNode.id.name, lexicalScopeNode);
         } else {
         } else {
-            this.identifierObfuscatingReplacer.storeLocalName(functionDeclarationNode.id.name, blockScopeNode);
+            this.identifierObfuscatingReplacer.storeLocalName(functionDeclarationNode.id.name, lexicalScopeNode);
         }
         }
     }
     }
 
 
     /**
     /**
      * @param {FunctionDeclaration} functionDeclarationNode
      * @param {FunctionDeclaration} functionDeclarationNode
-     * @param {TNodeWithBlockScope} blockScopeNode
+     * @param {TNodeWithLexicalScope} lexicalScopeNode
      */
      */
     private replaceScopeCachedIdentifiers (
     private replaceScopeCachedIdentifiers (
         functionDeclarationNode: ESTree.FunctionDeclaration,
         functionDeclarationNode: ESTree.FunctionDeclaration,
-        blockScopeNode: TNodeWithBlockScope
+        lexicalScopeNode: TNodeWithLexicalScope
     ): void {
     ): void {
         const cachedReplaceableIdentifiersNamesMap: TReplaceableIdentifiersNames =
         const cachedReplaceableIdentifiersNamesMap: TReplaceableIdentifiersNames =
-            <TReplaceableIdentifiersNames>this.replaceableIdentifiers.get(blockScopeNode);
+            <TReplaceableIdentifiersNames>this.replaceableIdentifiers.get(lexicalScopeNode);
 
 
         const cachedReplaceableIdentifiers: ESTree.Identifier[] | undefined = cachedReplaceableIdentifiersNamesMap
         const cachedReplaceableIdentifiers: ESTree.Identifier[] | undefined = cachedReplaceableIdentifiersNamesMap
             .get(functionDeclarationNode.id.name);
             .get(functionDeclarationNode.id.name);
@@ -151,7 +156,7 @@ export class FunctionDeclarationTransformer extends AbstractNodeTransformer {
         for (let i: number = 0; i < cachedReplaceableIdentifierLength; i++) {
         for (let i: number = 0; i < cachedReplaceableIdentifierLength; i++) {
             const replaceableIdentifier: ESTree.Identifier = cachedReplaceableIdentifiers[i];
             const replaceableIdentifier: ESTree.Identifier = cachedReplaceableIdentifiers[i];
             const newReplaceableIdentifier: ESTree.Identifier = this.identifierObfuscatingReplacer
             const newReplaceableIdentifier: ESTree.Identifier = this.identifierObfuscatingReplacer
-                .replace(replaceableIdentifier.name, blockScopeNode);
+                .replace(replaceableIdentifier.name, lexicalScopeNode);
 
 
             replaceableIdentifier.name = newReplaceableIdentifier.name;
             replaceableIdentifier.name = newReplaceableIdentifier.name;
             NodeMetadata.set(replaceableIdentifier, { renamedIdentifier: true });
             NodeMetadata.set(replaceableIdentifier, { renamedIdentifier: true });
@@ -159,12 +164,12 @@ export class FunctionDeclarationTransformer extends AbstractNodeTransformer {
     }
     }
 
 
     /**
     /**
-     * @param {TNodeWithBlockScope} blockScopeNode
+     * @param {TNodeWithLexicalScope} lexicalScopeNode
      */
      */
-    private replaceScopeIdentifiers (blockScopeNode: TNodeWithBlockScope): void {
+    private replaceScopeIdentifiers (lexicalScopeNode: TNodeWithLexicalScope): void {
         const storedReplaceableIdentifiersNamesMap: TReplaceableIdentifiersNames = new Map();
         const storedReplaceableIdentifiersNamesMap: TReplaceableIdentifiersNames = new Map();
 
 
-        estraverse.replace(blockScopeNode, {
+        estraverse.replace(lexicalScopeNode, {
             enter: (node: ESTree.Node, parentNode: ESTree.Node | null): void => {
             enter: (node: ESTree.Node, parentNode: ESTree.Node | null): void => {
                 if (
                 if (
                     parentNode
                     parentNode
@@ -172,7 +177,7 @@ export class FunctionDeclarationTransformer extends AbstractNodeTransformer {
                     && !NodeMetadata.isRenamedIdentifier(node)
                     && !NodeMetadata.isRenamedIdentifier(node)
                 ) {
                 ) {
                     const newIdentifier: ESTree.Identifier = this.identifierObfuscatingReplacer
                     const newIdentifier: ESTree.Identifier = this.identifierObfuscatingReplacer
-                        .replace(node.name, blockScopeNode);
+                        .replace(node.name, lexicalScopeNode);
                     const newIdentifierName: string = newIdentifier.name;
                     const newIdentifierName: string = newIdentifier.name;
 
 
                     if (node.name !== newIdentifierName) {
                     if (node.name !== newIdentifierName) {
@@ -189,6 +194,6 @@ export class FunctionDeclarationTransformer extends AbstractNodeTransformer {
             }
             }
         });
         });
 
 
-        this.replaceableIdentifiers.set(blockScopeNode, storedReplaceableIdentifiersNamesMap);
+        this.replaceableIdentifiers.set(lexicalScopeNode, storedReplaceableIdentifiersNamesMap);
     }
     }
 }
 }

+ 50 - 46
src/node-transformers/obfuscating-transformers/FunctionTransformer.ts

@@ -5,7 +5,7 @@ import * as estraverse from 'estraverse';
 import * as ESTree from 'estree';
 import * as ESTree from 'estree';
 
 
 import { TIdentifierObfuscatingReplacerFactory } from '../../types/container/node-transformers/TIdentifierObfuscatingReplacerFactory';
 import { TIdentifierObfuscatingReplacerFactory } from '../../types/container/node-transformers/TIdentifierObfuscatingReplacerFactory';
-import { TNodeWithBlockScope } from '../../types/node/TNodeWithBlockScope';
+import { TNodeWithLexicalScope } from '../../types/node/TNodeWithLexicalScope';
 
 
 import { IIdentifierObfuscatingReplacer } from '../../interfaces/node-transformers/obfuscating-transformers/obfuscating-replacers/IIdentifierObfuscatingReplacer';
 import { IIdentifierObfuscatingReplacer } from '../../interfaces/node-transformers/obfuscating-transformers/obfuscating-replacers/IIdentifierObfuscatingReplacer';
 import { IOptions } from '../../interfaces/options/IOptions';
 import { IOptions } from '../../interfaces/options/IOptions';
@@ -17,8 +17,8 @@ import { TransformationStage } from '../../enums/node-transformers/Transformatio
 
 
 import { AbstractNodeTransformer } from '../AbstractNodeTransformer';
 import { AbstractNodeTransformer } from '../AbstractNodeTransformer';
 import { NodeGuards } from '../../node/NodeGuards';
 import { NodeGuards } from '../../node/NodeGuards';
+import { NodeLexicalScopeUtils } from '../../node/NodeLexicalScopeUtils';
 import { NodeMetadata } from '../../node/NodeMetadata';
 import { NodeMetadata } from '../../node/NodeMetadata';
-import { NodeUtils } from '../../node/NodeUtils';
 
 
 /**
 /**
  * replaces:
  * replaces:
@@ -53,6 +53,16 @@ export class FunctionTransformer extends AbstractNodeTransformer {
         );
         );
     }
     }
 
 
+    /**
+     * @param {Node} node
+     * @returns {boolean}
+     */
+    private static isProhibitedPropertyNode (node: ESTree.Node): node is ESTree.Property & {key: ESTree.Identifier} {
+        return NodeGuards.isPropertyNode(node)
+            && node.shorthand
+            && NodeGuards.isIdentifierNode(node.key);
+    }
+
     /**
     /**
      * @param {TransformationStage} transformationStage
      * @param {TransformationStage} transformationStage
      * @returns {IVisitor | null}
      * @returns {IVisitor | null}
@@ -62,13 +72,7 @@ export class FunctionTransformer extends AbstractNodeTransformer {
             case TransformationStage.Obfuscating:
             case TransformationStage.Obfuscating:
                 return {
                 return {
                     enter: (node: ESTree.Node, parentNode: ESTree.Node | null) => {
                     enter: (node: ESTree.Node, parentNode: ESTree.Node | null) => {
-                        if (
-                            parentNode && (
-                                NodeGuards.isFunctionDeclarationNode(node) ||
-                                NodeGuards.isFunctionExpressionNode(node) ||
-                                NodeGuards.isArrowFunctionExpressionNode(node)
-                            )
-                        ) {
+                        if (parentNode && NodeGuards.isFunctionNode(node)) {
                             return this.transformNode(node, parentNode);
                             return this.transformNode(node, parentNode);
                         }
                         }
                     }
                     }
@@ -85,37 +89,39 @@ export class FunctionTransformer extends AbstractNodeTransformer {
      * @returns {NodeGuards}
      * @returns {NodeGuards}
      */
      */
     public transformNode (functionNode: ESTree.Function, parentNode: ESTree.Node): ESTree.Node {
     public transformNode (functionNode: ESTree.Function, parentNode: ESTree.Node): ESTree.Node {
-        const blockScopeNode: TNodeWithBlockScope = NodeGuards.isBlockStatementNode(functionNode.body)
-            ? functionNode.body
-            : NodeUtils.getBlockScopeOfNode(functionNode.body);
+        const lexicalScopeNode: TNodeWithLexicalScope | undefined = NodeLexicalScopeUtils.getLexicalScope(functionNode);
 
 
-        this.storeFunctionParams(functionNode, blockScopeNode);
-        this.replaceFunctionParams(functionNode, blockScopeNode);
+        if (!lexicalScopeNode) {
+            return functionNode;
+        }
+
+        this.storeFunctionParams(functionNode, lexicalScopeNode);
+        this.replaceFunctionParams(functionNode, lexicalScopeNode);
 
 
         return functionNode;
         return functionNode;
     }
     }
 
 
     /**
     /**
      * @param {Function} functionNode
      * @param {Function} functionNode
-     * @param {TNodeWithBlockScope} blockScopeNode
+     * @param {TNodeWithLexicalScope} lexicalScopeNode
      */
      */
-    private storeFunctionParams (functionNode: ESTree.Function, blockScopeNode: TNodeWithBlockScope): void {
+    private storeFunctionParams (functionNode: ESTree.Function, lexicalScopeNode: TNodeWithLexicalScope): void {
         functionNode.params
         functionNode.params
             .forEach((paramsNode: ESTree.Node) => {
             .forEach((paramsNode: ESTree.Node) => {
                 estraverse.traverse(paramsNode, {
                 estraverse.traverse(paramsNode, {
                     enter: (node: ESTree.Node): estraverse.VisitorOption | void => {
                     enter: (node: ESTree.Node): estraverse.VisitorOption | void => {
-                        if (NodeGuards.isPropertyNode(paramsNode)) {
+                        if (FunctionTransformer.isProhibitedPropertyNode(node)) {
                             return estraverse.VisitorOption.Skip;
                             return estraverse.VisitorOption.Skip;
                         }
                         }
 
 
                         if (NodeGuards.isAssignmentPatternNode(node) && NodeGuards.isIdentifierNode(node.left)) {
                         if (NodeGuards.isAssignmentPatternNode(node) && NodeGuards.isIdentifierNode(node.left)) {
-                            this.identifierObfuscatingReplacer.storeLocalName(node.left.name, blockScopeNode);
+                            this.identifierObfuscatingReplacer.storeLocalName(node.left.name, lexicalScopeNode);
 
 
                             return estraverse.VisitorOption.Skip;
                             return estraverse.VisitorOption.Skip;
                         }
                         }
 
 
                         if (NodeGuards.isIdentifierNode(node)) {
                         if (NodeGuards.isIdentifierNode(node)) {
-                            this.identifierObfuscatingReplacer.storeLocalName(node.name, blockScopeNode);
+                            this.identifierObfuscatingReplacer.storeLocalName(node.name, lexicalScopeNode);
                         }
                         }
                     }
                     }
                 });
                 });
@@ -123,42 +129,40 @@ export class FunctionTransformer extends AbstractNodeTransformer {
     }
     }
 
 
     /**
     /**
-     * @param {Property[]} properties
+     * @param {Function} functionNode
+     * @param {TNodeWithLexicalScope} lexicalScopeNode
      * @param {Set<string>} ignoredIdentifierNamesSet
      * @param {Set<string>} ignoredIdentifierNamesSet
      */
      */
-    private addIdentifiersToIgnoredIdentifierNamesSet (
-        properties: ESTree.Property[],
-        ignoredIdentifierNamesSet: Set<string>
+    private replaceFunctionParams (
+        functionNode: ESTree.Function,
+        lexicalScopeNode: TNodeWithLexicalScope,
+        ignoredIdentifierNamesSet: Set <string> = new Set()
     ): void {
     ): void {
-        properties.forEach((property: ESTree.Property) => {
-            if (!property.key || !NodeGuards.isIdentifierNode(property.key)) {
-                return;
-            }
-
-            ignoredIdentifierNamesSet.add(property.key.name);
-        });
-    }
-
-    /**
-     * @param {Function} functionNode
-     * @param {TNodeWithBlockScope} blockScopeNode
-     */
-    private replaceFunctionParams (functionNode: ESTree.Function, blockScopeNode: TNodeWithBlockScope): void {
-        const ignoredIdentifierNamesSet: Set<string> = new Set();
-
         const replaceVisitor: estraverse.Visitor = {
         const replaceVisitor: estraverse.Visitor = {
-            enter: (node: ESTree.Node, parentNode: ESTree.Node | null): void => {
-                if (NodeGuards.isObjectPatternNode(node)) {
-                    this.addIdentifiersToIgnoredIdentifierNamesSet(node.properties, ignoredIdentifierNamesSet);
+            enter: (node: ESTree.Node, parentNode: ESTree.Node | null): void | estraverse.VisitorOption => {
+                /**
+                 * Should to process nested functions in different traverse loop to avoid wrong code generation
+                 */
+                if (NodeGuards.isFunctionNode(node)) {
+                    this.replaceFunctionParams(node, lexicalScopeNode, new Set(ignoredIdentifierNamesSet));
+
+                    return estraverse.VisitorOption.Skip;
+                }
+
+                /**
+                 * Should to ignore all identifiers that related to shorthand properties
+                 */
+                if (FunctionTransformer.isProhibitedPropertyNode(node)) {
+                    ignoredIdentifierNamesSet.add(node.key.name);
                 }
                 }
 
 
                 if (
                 if (
-                    parentNode &&
-                    NodeGuards.isReplaceableIdentifierNode(node, parentNode) &&
-                    !ignoredIdentifierNamesSet.has(node.name)
+                    parentNode
+                    && NodeGuards.isReplaceableIdentifierNode(node, parentNode)
+                    && !ignoredIdentifierNamesSet.has(node.name)
                 ) {
                 ) {
                     const newIdentifier: ESTree.Identifier = this.identifierObfuscatingReplacer
                     const newIdentifier: ESTree.Identifier = this.identifierObfuscatingReplacer
-                        .replace(node.name, blockScopeNode);
+                        .replace(node.name, lexicalScopeNode);
                     const newIdentifierName: string = newIdentifier.name;
                     const newIdentifierName: string = newIdentifier.name;
 
 
                     if (node.name !== newIdentifierName) {
                     if (node.name !== newIdentifierName) {

+ 23 - 19
src/node-transformers/obfuscating-transformers/ImportDeclarationTransformer.ts

@@ -6,7 +6,7 @@ import * as ESTree from 'estree';
 
 
 import { TIdentifierObfuscatingReplacerFactory } from "../../types/container/node-transformers/TIdentifierObfuscatingReplacerFactory";
 import { TIdentifierObfuscatingReplacerFactory } from "../../types/container/node-transformers/TIdentifierObfuscatingReplacerFactory";
 import { TImportSpecifier } from '../../types/node/TimportSpecifier';
 import { TImportSpecifier } from '../../types/node/TimportSpecifier';
-import { TNodeWithBlockScope } from '../../types/node/TNodeWithBlockScope';
+import { TNodeWithLexicalScope } from '../../types/node/TNodeWithLexicalScope';
 
 
 import { IIdentifierObfuscatingReplacer } from '../../interfaces/node-transformers/obfuscating-transformers/obfuscating-replacers/IIdentifierObfuscatingReplacer';
 import { IIdentifierObfuscatingReplacer } from '../../interfaces/node-transformers/obfuscating-transformers/obfuscating-replacers/IIdentifierObfuscatingReplacer';
 import { IOptions } from '../../interfaces/options/IOptions';
 import { IOptions } from '../../interfaces/options/IOptions';
@@ -18,8 +18,8 @@ import { TransformationStage } from '../../enums/node-transformers/Transformatio
 
 
 import { AbstractNodeTransformer } from '../AbstractNodeTransformer';
 import { AbstractNodeTransformer } from '../AbstractNodeTransformer';
 import { NodeGuards } from '../../node/NodeGuards';
 import { NodeGuards } from '../../node/NodeGuards';
+import { NodeLexicalScopeUtils } from '../../node/NodeLexicalScopeUtils';
 import { NodeMetadata } from '../../node/NodeMetadata';
 import { NodeMetadata } from '../../node/NodeMetadata';
-import { NodeUtils } from '../../node/NodeUtils';
 
 
 /**
 /**
  * replaces:
  * replaces:
@@ -95,15 +95,19 @@ export class ImportDeclarationTransformer extends AbstractNodeTransformer {
      * @returns {Node}
      * @returns {Node}
      */
      */
     public transformNode (importDeclarationNode: ESTree.ImportDeclaration, parentNode: ESTree.Node): ESTree.Node {
     public transformNode (importDeclarationNode: ESTree.ImportDeclaration, parentNode: ESTree.Node): ESTree.Node {
-        const blockScopeNode: TNodeWithBlockScope = NodeUtils.getBlockScopeOfNode(importDeclarationNode);
+        const lexicalScopeNode: TNodeWithLexicalScope | undefined = NodeLexicalScopeUtils.getLexicalScope(importDeclarationNode);
 
 
-        this.storeImportSpecifierNames(importDeclarationNode, blockScopeNode);
+        if (!lexicalScopeNode) {
+            return importDeclarationNode;
+        }
+
+        this.storeImportSpecifierNames(importDeclarationNode, lexicalScopeNode);
 
 
         // check for cached identifiers for current scope node. If exist - loop through them.
         // check for cached identifiers for current scope node. If exist - loop through them.
-        if (this.replaceableIdentifiers.has(blockScopeNode)) {
-            this.replaceScopeCachedIdentifiers(blockScopeNode);
+        if (this.replaceableIdentifiers.has(lexicalScopeNode)) {
+            this.replaceScopeCachedIdentifiers(lexicalScopeNode);
         } else {
         } else {
-            this.replaceScopeIdentifiers(blockScopeNode);
+            this.replaceScopeIdentifiers(lexicalScopeNode);
         }
         }
 
 
         return importDeclarationNode;
         return importDeclarationNode;
@@ -111,31 +115,31 @@ export class ImportDeclarationTransformer extends AbstractNodeTransformer {
 
 
     /**
     /**
      * @param {ImportDeclaration} importDeclarationNode
      * @param {ImportDeclaration} importDeclarationNode
-     * @param {TNodeWithBlockScope} blockScopeNode
+     * @param {TNodeWithLexicalScope} lexicalScopeNode
      */
      */
     private storeImportSpecifierNames (
     private storeImportSpecifierNames (
         importDeclarationNode: ESTree.ImportDeclaration,
         importDeclarationNode: ESTree.ImportDeclaration,
-        blockScopeNode: TNodeWithBlockScope
+        lexicalScopeNode: TNodeWithLexicalScope
     ): void {
     ): void {
         importDeclarationNode.specifiers.forEach((importSpecifierNode: TImportSpecifier) => {
         importDeclarationNode.specifiers.forEach((importSpecifierNode: TImportSpecifier) => {
             if (ImportDeclarationTransformer.isProhibitedImportSpecifierNode(importSpecifierNode)) {
             if (ImportDeclarationTransformer.isProhibitedImportSpecifierNode(importSpecifierNode)) {
                 return;
                 return;
             }
             }
 
 
-            this.identifierObfuscatingReplacer.storeGlobalName(importSpecifierNode.local.name, blockScopeNode);
+            this.identifierObfuscatingReplacer.storeGlobalName(importSpecifierNode.local.name, lexicalScopeNode);
         });
         });
     }
     }
 
 
     /**
     /**
-     * @param {TNodeWithBlockScope} blockScopeNode
+     * @param {TNodeWithLexicalScope} lexicalScopeNode
      */
      */
-    private replaceScopeCachedIdentifiers (blockScopeNode: TNodeWithBlockScope): void {
+    private replaceScopeCachedIdentifiers (lexicalScopeNode: TNodeWithLexicalScope): void {
         const cachedReplaceableIdentifiers: ESTree.Identifier[] =
         const cachedReplaceableIdentifiers: ESTree.Identifier[] =
-            <ESTree.Identifier[]>this.replaceableIdentifiers.get(blockScopeNode);
+            <ESTree.Identifier[]>this.replaceableIdentifiers.get(lexicalScopeNode);
 
 
         cachedReplaceableIdentifiers.forEach((replaceableIdentifier: ESTree.Identifier) => {
         cachedReplaceableIdentifiers.forEach((replaceableIdentifier: ESTree.Identifier) => {
             const newReplaceableIdentifier: ESTree.Identifier = this.identifierObfuscatingReplacer
             const newReplaceableIdentifier: ESTree.Identifier = this.identifierObfuscatingReplacer
-                .replace(replaceableIdentifier.name, blockScopeNode);
+                .replace(replaceableIdentifier.name, lexicalScopeNode);
 
 
             replaceableIdentifier.name = newReplaceableIdentifier.name;
             replaceableIdentifier.name = newReplaceableIdentifier.name;
             NodeMetadata.set(replaceableIdentifier, { renamedIdentifier: true });
             NodeMetadata.set(replaceableIdentifier, { renamedIdentifier: true });
@@ -143,12 +147,12 @@ export class ImportDeclarationTransformer extends AbstractNodeTransformer {
     }
     }
 
 
     /**
     /**
-     * @param {TNodeWithBlockScope} blockScopeNode
+     * @param {TNodeWithLexicalScope} lexicalScopeNode
      */
      */
-    private replaceScopeIdentifiers (blockScopeNode: TNodeWithBlockScope): void {
+    private replaceScopeIdentifiers (lexicalScopeNode: TNodeWithLexicalScope): void {
         const storedReplaceableIdentifiers: ESTree.Identifier[] = [];
         const storedReplaceableIdentifiers: ESTree.Identifier[] = [];
 
 
-        estraverse.replace(blockScopeNode, {
+        estraverse.replace(lexicalScopeNode, {
             enter: (node: ESTree.Node, parentNode: ESTree.Node | null): void => {
             enter: (node: ESTree.Node, parentNode: ESTree.Node | null): void => {
                 if (
                 if (
                     parentNode
                     parentNode
@@ -156,7 +160,7 @@ export class ImportDeclarationTransformer extends AbstractNodeTransformer {
                     && !NodeMetadata.isRenamedIdentifier(node)
                     && !NodeMetadata.isRenamedIdentifier(node)
                 ) {
                 ) {
                     const newIdentifier: ESTree.Identifier = this.identifierObfuscatingReplacer
                     const newIdentifier: ESTree.Identifier = this.identifierObfuscatingReplacer
-                        .replace(node.name, blockScopeNode);
+                        .replace(node.name, lexicalScopeNode);
                     const newIdentifierName: string = newIdentifier.name;
                     const newIdentifierName: string = newIdentifier.name;
 
 
                     if (node.name !== newIdentifierName) {
                     if (node.name !== newIdentifierName) {
@@ -169,6 +173,6 @@ export class ImportDeclarationTransformer extends AbstractNodeTransformer {
             }
             }
         });
         });
 
 
-        this.replaceableIdentifiers.set(blockScopeNode, storedReplaceableIdentifiers);
+        this.replaceableIdentifiers.set(lexicalScopeNode, storedReplaceableIdentifiers);
     }
     }
 }
 }

+ 15 - 11
src/node-transformers/obfuscating-transformers/LabeledStatementTransformer.ts

@@ -5,6 +5,7 @@ import * as estraverse from 'estraverse';
 import * as ESTree from 'estree';
 import * as ESTree from 'estree';
 
 
 import { TIdentifierObfuscatingReplacerFactory } from '../../types/container/node-transformers/TIdentifierObfuscatingReplacerFactory';
 import { TIdentifierObfuscatingReplacerFactory } from '../../types/container/node-transformers/TIdentifierObfuscatingReplacerFactory';
+import { TNodeWithLexicalScope } from '../../types/node/TNodeWithLexicalScope';
 
 
 import { IIdentifierObfuscatingReplacer } from '../../interfaces/node-transformers/obfuscating-transformers/obfuscating-replacers/IIdentifierObfuscatingReplacer';
 import { IIdentifierObfuscatingReplacer } from '../../interfaces/node-transformers/obfuscating-transformers/obfuscating-replacers/IIdentifierObfuscatingReplacer';
 import { IOptions } from '../../interfaces/options/IOptions';
 import { IOptions } from '../../interfaces/options/IOptions';
@@ -16,8 +17,7 @@ import { TransformationStage } from '../../enums/node-transformers/Transformatio
 
 
 import { AbstractNodeTransformer } from '../AbstractNodeTransformer';
 import { AbstractNodeTransformer } from '../AbstractNodeTransformer';
 import { NodeGuards } from '../../node/NodeGuards';
 import { NodeGuards } from '../../node/NodeGuards';
-import { TNodeWithBlockScope } from '../../types/node/TNodeWithBlockScope';
-import { NodeUtils } from '../../node/NodeUtils';
+import { NodeLexicalScopeUtils } from '../../node/NodeLexicalScopeUtils';
 
 
 /**
 /**
  * replaces:
  * replaces:
@@ -86,38 +86,42 @@ export class LabeledStatementTransformer extends AbstractNodeTransformer {
      * @returns {NodeGuards}
      * @returns {NodeGuards}
      */
      */
     public transformNode (labeledStatementNode: ESTree.LabeledStatement, parentNode: ESTree.Node): ESTree.Node {
     public transformNode (labeledStatementNode: ESTree.LabeledStatement, parentNode: ESTree.Node): ESTree.Node {
-        const blockScopeNode: TNodeWithBlockScope = NodeUtils.getBlockScopeOfNode(labeledStatementNode);
+        const lexicalScopeNode: TNodeWithLexicalScope | undefined = NodeLexicalScopeUtils.getLexicalScope(labeledStatementNode);
 
 
-        this.storeLabeledStatementName(labeledStatementNode, blockScopeNode);
-        this.replaceLabeledStatementName(labeledStatementNode, blockScopeNode);
+        if (!lexicalScopeNode) {
+            return labeledStatementNode;
+        }
+
+        this.storeLabeledStatementName(labeledStatementNode, lexicalScopeNode);
+        this.replaceLabeledStatementName(labeledStatementNode, lexicalScopeNode);
 
 
         return labeledStatementNode;
         return labeledStatementNode;
     }
     }
 
 
     /**
     /**
      * @param {LabeledStatement} labeledStatementNode
      * @param {LabeledStatement} labeledStatementNode
-     * @param {TNodeWithBlockScope} blockScopeNode
+     * @param {TNodeWithLexicalScope} lexicalScopeNode
      */
      */
     private storeLabeledStatementName (
     private storeLabeledStatementName (
         labeledStatementNode: ESTree.LabeledStatement,
         labeledStatementNode: ESTree.LabeledStatement,
-        blockScopeNode: TNodeWithBlockScope
+        lexicalScopeNode: TNodeWithLexicalScope
     ): void {
     ): void {
-        this.identifierObfuscatingReplacer.storeLocalName(labeledStatementNode.label.name, blockScopeNode);
+        this.identifierObfuscatingReplacer.storeLocalName(labeledStatementNode.label.name, lexicalScopeNode);
     }
     }
 
 
     /**
     /**
      * @param {LabeledStatement} labeledStatementNode
      * @param {LabeledStatement} labeledStatementNode
-     * @param {TNodeWithBlockScope} blockScopeNode
+     * @param {TNodeWithLexicalScope} lexicalScopeNode
      */
      */
     private replaceLabeledStatementName (
     private replaceLabeledStatementName (
         labeledStatementNode: ESTree.LabeledStatement,
         labeledStatementNode: ESTree.LabeledStatement,
-        blockScopeNode: TNodeWithBlockScope
+        lexicalScopeNode: TNodeWithLexicalScope
     ): void {
     ): void {
         estraverse.replace(labeledStatementNode, {
         estraverse.replace(labeledStatementNode, {
             enter: (node: ESTree.Node, parentNode: ESTree.Node | null): void => {
             enter: (node: ESTree.Node, parentNode: ESTree.Node | null): void => {
                 if (parentNode && NodeGuards.isLabelIdentifierNode(node, parentNode)) {
                 if (parentNode && NodeGuards.isLabelIdentifierNode(node, parentNode)) {
                     const newIdentifier: ESTree.Identifier = this.identifierObfuscatingReplacer
                     const newIdentifier: ESTree.Identifier = this.identifierObfuscatingReplacer
-                        .replace(node.name, blockScopeNode);
+                        .replace(node.name, lexicalScopeNode);
 
 
                     node.name = newIdentifier.name;
                     node.name = newIdentifier.name;
                 }
                 }

+ 23 - 18
src/node-transformers/obfuscating-transformers/VariableDeclarationTransformer.ts

@@ -5,7 +5,7 @@ import * as estraverse from 'estraverse';
 import * as ESTree from 'estree';
 import * as ESTree from 'estree';
 
 
 import { TIdentifierObfuscatingReplacerFactory } from '../../types/container/node-transformers/TIdentifierObfuscatingReplacerFactory';
 import { TIdentifierObfuscatingReplacerFactory } from '../../types/container/node-transformers/TIdentifierObfuscatingReplacerFactory';
-import { TNodeWithBlockScope } from '../../types/node/TNodeWithBlockScope';
+import { TNodeWithLexicalScope } from '../../types/node/TNodeWithLexicalScope';
 import { TReplaceableIdentifiers } from '../../types/node-transformers/TReplaceableIdentifiers';
 import { TReplaceableIdentifiers } from '../../types/node-transformers/TReplaceableIdentifiers';
 import { TReplaceableIdentifiersNames } from '../../types/node-transformers/TReplaceableIdentifiersNames';
 import { TReplaceableIdentifiersNames } from '../../types/node-transformers/TReplaceableIdentifiersNames';
 
 
@@ -20,8 +20,8 @@ import { TransformationStage } from '../../enums/node-transformers/Transformatio
 
 
 import { AbstractNodeTransformer } from '../AbstractNodeTransformer';
 import { AbstractNodeTransformer } from '../AbstractNodeTransformer';
 import { NodeGuards } from '../../node/NodeGuards';
 import { NodeGuards } from '../../node/NodeGuards';
+import { NodeLexicalScopeUtils } from '../../node/NodeLexicalScopeUtils';
 import { NodeMetadata } from '../../node/NodeMetadata';
 import { NodeMetadata } from '../../node/NodeMetadata';
-import { NodeUtils } from '../../node/NodeUtils';
 
 
 /**
 /**
  * replaces:
  * replaces:
@@ -93,24 +93,29 @@ export class VariableDeclarationTransformer extends AbstractNodeTransformer {
      * @returns {NodeGuards}
      * @returns {NodeGuards}
      */
      */
     public transformNode (variableDeclarationNode: ESTree.VariableDeclaration, parentNode: ESTree.Node): ESTree.Node {
     public transformNode (variableDeclarationNode: ESTree.VariableDeclaration, parentNode: ESTree.Node): ESTree.Node {
-        const blockScopeNode: TNodeWithBlockScope = NodeUtils.getBlockScopeOfNode(variableDeclarationNode);
-        const isGlobalDeclaration: boolean = blockScopeNode.type === NodeType.Program;
+        const lexicalScopeNode: TNodeWithLexicalScope | undefined = NodeLexicalScopeUtils.getLexicalScope(variableDeclarationNode);
+
+        if (!lexicalScopeNode) {
+            return variableDeclarationNode;
+        }
+
+        const isGlobalDeclaration: boolean = lexicalScopeNode.type === NodeType.Program;
 
 
         if (!this.options.renameGlobals && isGlobalDeclaration) {
         if (!this.options.renameGlobals && isGlobalDeclaration) {
             return variableDeclarationNode;
             return variableDeclarationNode;
         }
         }
 
 
         const scopeNode: ESTree.Node = variableDeclarationNode.kind === 'var'
         const scopeNode: ESTree.Node = variableDeclarationNode.kind === 'var'
-            ? blockScopeNode
+            ? lexicalScopeNode
             : parentNode;
             : parentNode;
 
 
-        this.storeVariableNames(variableDeclarationNode, blockScopeNode, isGlobalDeclaration);
+        this.storeVariableNames(variableDeclarationNode, lexicalScopeNode, isGlobalDeclaration);
 
 
         // check for cached identifiers for current scope node. If exist - loop through them.
         // check for cached identifiers for current scope node. If exist - loop through them.
         if (this.replaceableIdentifiers.has(scopeNode)) {
         if (this.replaceableIdentifiers.has(scopeNode)) {
-            this.replaceScopeCachedIdentifiers(variableDeclarationNode, blockScopeNode, scopeNode);
+            this.replaceScopeCachedIdentifiers(variableDeclarationNode, lexicalScopeNode, scopeNode);
         } else {
         } else {
-            this.replaceScopeIdentifiers(scopeNode, blockScopeNode);
+            this.replaceScopeIdentifiers(scopeNode, lexicalScopeNode);
         }
         }
 
 
         return variableDeclarationNode;
         return variableDeclarationNode;
@@ -118,31 +123,31 @@ export class VariableDeclarationTransformer extends AbstractNodeTransformer {
 
 
     /**
     /**
      * @param {VariableDeclaration} variableDeclarationNode
      * @param {VariableDeclaration} variableDeclarationNode
-     * @param {TNodeWithBlockScope} blockScopeNode
+     * @param {TNodeWithLexicalScope} lexicalScopeNode
      * @param {boolean} isGlobalDeclaration
      * @param {boolean} isGlobalDeclaration
      */
      */
     private storeVariableNames (
     private storeVariableNames (
         variableDeclarationNode: ESTree.VariableDeclaration,
         variableDeclarationNode: ESTree.VariableDeclaration,
-        blockScopeNode: TNodeWithBlockScope,
+        lexicalScopeNode: TNodeWithLexicalScope,
         isGlobalDeclaration: boolean
         isGlobalDeclaration: boolean
     ): void {
     ): void {
         this.traverseDeclarationIdentifiers(variableDeclarationNode, (identifierNode: ESTree.Identifier) => {
         this.traverseDeclarationIdentifiers(variableDeclarationNode, (identifierNode: ESTree.Identifier) => {
             if (isGlobalDeclaration) {
             if (isGlobalDeclaration) {
-                this.identifierObfuscatingReplacer.storeGlobalName(identifierNode.name, blockScopeNode);
+                this.identifierObfuscatingReplacer.storeGlobalName(identifierNode.name, lexicalScopeNode);
             } else {
             } else {
-                this.identifierObfuscatingReplacer.storeLocalName(identifierNode.name, blockScopeNode);
+                this.identifierObfuscatingReplacer.storeLocalName(identifierNode.name, lexicalScopeNode);
             }
             }
         });
         });
     }
     }
 
 
     /**
     /**
      * @param {VariableDeclaration} variableDeclarationNode
      * @param {VariableDeclaration} variableDeclarationNode
-     * @param {TNodeWithBlockScope} blockScopeNode
+     * @param {TNodeWithLexicalScope} lexicalScopeNode
      * @param {Node} scopeNode
      * @param {Node} scopeNode
      */
      */
     private replaceScopeCachedIdentifiers (
     private replaceScopeCachedIdentifiers (
         variableDeclarationNode: ESTree.VariableDeclaration,
         variableDeclarationNode: ESTree.VariableDeclaration,
-        blockScopeNode: TNodeWithBlockScope,
+        lexicalScopeNode: TNodeWithLexicalScope,
         scopeNode: ESTree.Node
         scopeNode: ESTree.Node
     ): void {
     ): void {
         const cachedReplaceableIdentifiersNamesMap: TReplaceableIdentifiersNames =
         const cachedReplaceableIdentifiersNamesMap: TReplaceableIdentifiersNames =
@@ -172,7 +177,7 @@ export class VariableDeclarationTransformer extends AbstractNodeTransformer {
                 }
                 }
 
 
                 const newReplaceableIdentifier: ESTree.Identifier = this.identifierObfuscatingReplacer
                 const newReplaceableIdentifier: ESTree.Identifier = this.identifierObfuscatingReplacer
-                    .replace(replaceableIdentifier.name, blockScopeNode);
+                    .replace(replaceableIdentifier.name, lexicalScopeNode);
 
 
                 replaceableIdentifier.name = newReplaceableIdentifier.name;
                 replaceableIdentifier.name = newReplaceableIdentifier.name;
                 NodeMetadata.set(replaceableIdentifier, { renamedIdentifier: true });
                 NodeMetadata.set(replaceableIdentifier, { renamedIdentifier: true });
@@ -182,9 +187,9 @@ export class VariableDeclarationTransformer extends AbstractNodeTransformer {
 
 
     /**
     /**
      * @param {Node} scopeNode
      * @param {Node} scopeNode
-     * @param {TNodeWithBlockScope} blockScopeNode
+     * @param {TNodeWithLexicalScope} lexicalScopeNode
      */
      */
-    private replaceScopeIdentifiers (scopeNode: ESTree.Node, blockScopeNode: TNodeWithBlockScope): void {
+    private replaceScopeIdentifiers (scopeNode: ESTree.Node, lexicalScopeNode: TNodeWithLexicalScope): void {
         const storedReplaceableIdentifiersNamesMap: TReplaceableIdentifiersNames = new Map();
         const storedReplaceableIdentifiersNamesMap: TReplaceableIdentifiersNames = new Map();
 
 
         estraverse.replace(scopeNode, {
         estraverse.replace(scopeNode, {
@@ -195,7 +200,7 @@ export class VariableDeclarationTransformer extends AbstractNodeTransformer {
                     && !NodeMetadata.isRenamedIdentifier(node)
                     && !NodeMetadata.isRenamedIdentifier(node)
                 ) {
                 ) {
                     const newIdentifier: ESTree.Identifier = this.identifierObfuscatingReplacer
                     const newIdentifier: ESTree.Identifier = this.identifierObfuscatingReplacer
-                        .replace(node.name, blockScopeNode);
+                        .replace(node.name, lexicalScopeNode);
                     const newIdentifierName: string = newIdentifier.name;
                     const newIdentifierName: string = newIdentifier.name;
 
 
                     if (node.name !== newIdentifierName) {
                     if (node.name !== newIdentifierName) {

+ 3 - 3
src/node-transformers/obfuscating-transformers/obfuscating-replacers/AbstractObfuscatingReplacer.ts

@@ -3,7 +3,7 @@ import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers';
 
 
 import * as ESTree from 'estree';
 import * as ESTree from 'estree';
 
 
-import { TNodeWithBlockScope } from '../../../types/node/TNodeWithBlockScope';
+import { TNodeWithLexicalScope } from '../../../types/node/TNodeWithLexicalScope';
 
 
 import { IObfuscatingReplacer } from '../../../interfaces/node-transformers/obfuscating-transformers/obfuscating-replacers/IObfuscatingReplacer';
 import { IObfuscatingReplacer } from '../../../interfaces/node-transformers/obfuscating-transformers/obfuscating-replacers/IObfuscatingReplacer';
 import { IOptions } from '../../../interfaces/options/IOptions';
 import { IOptions } from '../../../interfaces/options/IOptions';
@@ -26,8 +26,8 @@ export abstract class AbstractObfuscatingReplacer implements IObfuscatingReplace
 
 
     /**
     /**
      * @param {SimpleLiteral["value"]} nodeValue
      * @param {SimpleLiteral["value"]} nodeValue
-     * @param {TNodeWithBlockScope} blockScopeNode
+     * @param {TNodeWithLexicalScope} lexicalScopeNode
      * @returns {Node}
      * @returns {Node}
      */
      */
-    public abstract replace (nodeValue: ESTree.SimpleLiteral['value'], blockScopeNode?: TNodeWithBlockScope): ESTree.Node;
+    public abstract replace (nodeValue: ESTree.SimpleLiteral['value'], lexicalScopeNode?: TNodeWithLexicalScope): ESTree.Node;
 }
 }

+ 17 - 17
src/node-transformers/obfuscating-transformers/obfuscating-replacers/identifier-obfuscating-replacers/BaseIdentifierObfuscatingReplacer.ts

@@ -4,7 +4,7 @@ import { ServiceIdentifiers } from '../../../../container/ServiceIdentifiers';
 import * as ESTree from 'estree';
 import * as ESTree from 'estree';
 
 
 import { TIdentifierNamesGeneratorFactory } from '../../../../types/container/generators/TIdentifierNamesGeneratorFactory';
 import { TIdentifierNamesGeneratorFactory } from '../../../../types/container/generators/TIdentifierNamesGeneratorFactory';
-import { TNodeWithBlockScope } from '../../../../types/node/TNodeWithBlockScope';
+import { TNodeWithLexicalScope } from '../../../../types/node/TNodeWithLexicalScope';
 
 
 import { IIdentifierNamesGenerator } from '../../../../interfaces/generators/identifier-names-generators/IIdentifierNamesGenerator';
 import { IIdentifierNamesGenerator } from '../../../../interfaces/generators/identifier-names-generators/IIdentifierNamesGenerator';
 import { IIdentifierObfuscatingReplacer } from '../../../../interfaces/node-transformers/obfuscating-transformers/obfuscating-replacers/IIdentifierObfuscatingReplacer';
 import { IIdentifierObfuscatingReplacer } from '../../../../interfaces/node-transformers/obfuscating-transformers/obfuscating-replacers/IIdentifierObfuscatingReplacer';
@@ -21,9 +21,9 @@ export class BaseIdentifierObfuscatingReplacer extends AbstractObfuscatingReplac
     private readonly identifierNamesGenerator: IIdentifierNamesGenerator;
     private readonly identifierNamesGenerator: IIdentifierNamesGenerator;
 
 
     /**
     /**
-     * @type {Map<TNodeWithBlockScope, Map<string, string>>}
+     * @type {Map<TNodeWithLexicalScope, Map<string, string>>}
      */
      */
-    private readonly blockScopesMap: Map<TNodeWithBlockScope, Map<string, string>> = new Map();
+    private readonly blockScopesMap: Map<TNodeWithLexicalScope, Map<string, string>> = new Map();
 
 
     /**
     /**
      * @param {TIdentifierNamesGeneratorFactory} identifierNamesGeneratorFactory
      * @param {TIdentifierNamesGeneratorFactory} identifierNamesGeneratorFactory
@@ -41,12 +41,12 @@ export class BaseIdentifierObfuscatingReplacer extends AbstractObfuscatingReplac
 
 
     /**
     /**
      * @param {string} nodeValue
      * @param {string} nodeValue
-     * @param {TNodeWithBlockScope} blockScopeNode
+     * @param {TNodeWithLexicalScope} lexicalScopeNode
      * @returns {Identifier}
      * @returns {Identifier}
      */
      */
-    public replace (nodeValue: string, blockScopeNode: TNodeWithBlockScope): ESTree.Identifier {
-        if (this.blockScopesMap.has(blockScopeNode)) {
-            const namesMap: Map<string, string> = <Map<string, string>>this.blockScopesMap.get(blockScopeNode);
+    public replace (nodeValue: string, lexicalScopeNode: TNodeWithLexicalScope): ESTree.Identifier {
+        if (this.blockScopesMap.has(lexicalScopeNode)) {
+            const namesMap: Map<string, string> = <Map<string, string>>this.blockScopesMap.get(lexicalScopeNode);
 
 
             if (namesMap.has(nodeValue)) {
             if (namesMap.has(nodeValue)) {
                 nodeValue = <string>namesMap.get(nodeValue);
                 nodeValue = <string>namesMap.get(nodeValue);
@@ -61,20 +61,20 @@ export class BaseIdentifierObfuscatingReplacer extends AbstractObfuscatingReplac
      * Reserved name will be ignored.
      * Reserved name will be ignored.
      *
      *
      * @param {string} nodeName
      * @param {string} nodeName
-     * @param {TNodeWithBlockScope} blockScopeNode
+     * @param {TNodeWithLexicalScope} lexicalScopeNode
      */
      */
-    public storeGlobalName (nodeName: string, blockScopeNode: TNodeWithBlockScope): void {
+    public storeGlobalName (nodeName: string, lexicalScopeNode: TNodeWithLexicalScope): void {
         if (this.isReservedName(nodeName)) {
         if (this.isReservedName(nodeName)) {
             return;
             return;
         }
         }
 
 
         const identifierName: string = this.identifierNamesGenerator.generateWithPrefix();
         const identifierName: string = this.identifierNamesGenerator.generateWithPrefix();
 
 
-        if (!this.blockScopesMap.has(blockScopeNode)) {
-            this.blockScopesMap.set(blockScopeNode, new Map());
+        if (!this.blockScopesMap.has(lexicalScopeNode)) {
+            this.blockScopesMap.set(lexicalScopeNode, new Map());
         }
         }
 
 
-        const namesMap: Map<string, string> = <Map<string, string>>this.blockScopesMap.get(blockScopeNode);
+        const namesMap: Map<string, string> = <Map<string, string>>this.blockScopesMap.get(lexicalScopeNode);
 
 
         namesMap.set(nodeName, identifierName);
         namesMap.set(nodeName, identifierName);
     }
     }
@@ -84,20 +84,20 @@ export class BaseIdentifierObfuscatingReplacer extends AbstractObfuscatingReplac
      * Reserved name will be ignored.
      * Reserved name will be ignored.
      *
      *
      * @param {string} nodeName
      * @param {string} nodeName
-     * @param {TNodeWithBlockScope} blockScopeNode
+     * @param {TNodeWithLexicalScope} lexicalScopeNode
      */
      */
-    public storeLocalName (nodeName: string, blockScopeNode: TNodeWithBlockScope): void {
+    public storeLocalName (nodeName: string, lexicalScopeNode: TNodeWithLexicalScope): void {
         if (this.isReservedName(nodeName)) {
         if (this.isReservedName(nodeName)) {
             return;
             return;
         }
         }
 
 
         const identifierName: string = this.identifierNamesGenerator.generate();
         const identifierName: string = this.identifierNamesGenerator.generate();
 
 
-        if (!this.blockScopesMap.has(blockScopeNode)) {
-            this.blockScopesMap.set(blockScopeNode, new Map());
+        if (!this.blockScopesMap.has(lexicalScopeNode)) {
+            this.blockScopesMap.set(lexicalScopeNode, new Map());
         }
         }
 
 
-        const namesMap: Map<string, string> = <Map<string, string>>this.blockScopesMap.get(blockScopeNode);
+        const namesMap: Map<string, string> = <Map<string, string>>this.blockScopesMap.get(lexicalScopeNode);
 
 
         namesMap.set(nodeName, identifierName);
         namesMap.set(nodeName, identifierName);
     }
     }

+ 42 - 39
src/node/NodeAppender.ts

@@ -1,22 +1,22 @@
 import * as ESTree from 'estree';
 import * as ESTree from 'estree';
 
 
-import { TNodeWithBlockScope } from '../types/node/TNodeWithBlockScope';
+import { TNodeWithStatements } from '../types/node/TNodeWithStatements';
 import { TStatement } from '../types/node/TStatement';
 import { TStatement } from '../types/node/TStatement';
 
 
 import { IStackTraceData } from '../interfaces/analyzers/stack-trace-analyzer/IStackTraceData';
 import { IStackTraceData } from '../interfaces/analyzers/stack-trace-analyzer/IStackTraceData';
-import { TNodeWithScope } from '../types/node/TNodeWithScope';
+
 import { NodeGuards } from './NodeGuards';
 import { NodeGuards } from './NodeGuards';
 
 
 export class NodeAppender {
 export class NodeAppender {
     /**
     /**
-     * @param {TNodeWithScope} scope
+     * @param {TNodeWithStatements} nodeWithStatements
      * @param {TStatement[]} statements
      * @param {TStatement[]} statements
      */
      */
-    public static append (scope: TNodeWithScope, statements: TStatement[]): void {
-        statements = NodeAppender.parentizeScopeStatementsBeforeAppend(scope, statements);
+    public static append (nodeWithStatements: TNodeWithStatements, statements: TStatement[]): void {
+        statements = NodeAppender.parentizeScopeStatementsBeforeAppend(nodeWithStatements, statements);
 
 
-        NodeAppender.setScopeStatements(scope, [
-            ...NodeAppender.getScopeStatements(scope),
+        NodeAppender.setScopeStatements(nodeWithStatements, [
+            ...NodeAppender.getScopeStatements(nodeWithStatements),
             ...statements
             ...statements
         ]);
         ]);
     }
     }
@@ -39,19 +39,19 @@ export class NodeAppender {
      * Appends node into block statement of `baz` function expression
      * Appends node into block statement of `baz` function expression
      *
      *
      * @param {IStackTraceData[]} stackTraceData
      * @param {IStackTraceData[]} stackTraceData
-     * @param {TNodeWithBlockScope} blockScopeNode
+     * @param {TNodeWithStatements} nodeWithStatements
      * @param {TStatement[]} bodyStatements
      * @param {TStatement[]} bodyStatements
      * @param {number} index
      * @param {number} index
      */
      */
     public static appendToOptimalBlockScope (
     public static appendToOptimalBlockScope (
         stackTraceData: IStackTraceData[],
         stackTraceData: IStackTraceData[],
-        blockScopeNode: TNodeWithBlockScope,
+        nodeWithStatements: TNodeWithStatements,
         bodyStatements: TStatement[],
         bodyStatements: TStatement[],
         index: number = 0
         index: number = 0
     ): void {
     ): void {
-        const targetBlockScope: TNodeWithBlockScope = stackTraceData.length
+        const targetBlockScope: TNodeWithStatements = stackTraceData.length
             ? NodeAppender.getOptimalBlockScope(stackTraceData, index)
             ? NodeAppender.getOptimalBlockScope(stackTraceData, index)
-            : blockScopeNode;
+            : nodeWithStatements;
 
 
         NodeAppender.prepend(targetBlockScope, bodyStatements);
         NodeAppender.prepend(targetBlockScope, bodyStatements);
     }
     }
@@ -83,90 +83,93 @@ export class NodeAppender {
     }
     }
 
 
     /**
     /**
-     * @param {TNodeWithScope} scope
+     * @param {TNodeWithStatements} nodeWithStatements
      * @param {TStatement[]} statements
      * @param {TStatement[]} statements
      * @param {Node} target
      * @param {Node} target
      */
      */
     public static insertAfter (
     public static insertAfter (
-        scope: TNodeWithScope,
+        nodeWithStatements: TNodeWithStatements,
         statements: TStatement[],
         statements: TStatement[],
         target: ESTree.Statement
         target: ESTree.Statement
     ): void {
     ): void {
         const indexInScopeStatement: number = NodeAppender
         const indexInScopeStatement: number = NodeAppender
-            .getScopeStatements(scope)
+            .getScopeStatements(nodeWithStatements)
             .indexOf(target);
             .indexOf(target);
 
 
-        NodeAppender.insertAtIndex(scope, statements, indexInScopeStatement + 1);
+        NodeAppender.insertAtIndex(nodeWithStatements, statements, indexInScopeStatement + 1);
     }
     }
 
 
     /**
     /**
-     * @param {TNodeWithScope} scope
+     * @param {TNodeWithStatements} nodeWithStatements
      * @param {TStatement[]} statements
      * @param {TStatement[]} statements
      * @param {number} index
      * @param {number} index
      */
      */
     public static insertAtIndex (
     public static insertAtIndex (
-        scope: TNodeWithScope,
+        nodeWithStatements: TNodeWithStatements,
         statements: TStatement[],
         statements: TStatement[],
         index: number
         index: number
     ): void {
     ): void {
-        statements = NodeAppender.parentizeScopeStatementsBeforeAppend(scope, statements);
+        statements = NodeAppender.parentizeScopeStatementsBeforeAppend(nodeWithStatements, statements);
 
 
-        NodeAppender.setScopeStatements(scope, [
-            ...NodeAppender.getScopeStatements(scope).slice(0, index),
+        NodeAppender.setScopeStatements(nodeWithStatements, [
+            ...NodeAppender.getScopeStatements(nodeWithStatements).slice(0, index),
             ...statements,
             ...statements,
-            ...NodeAppender.getScopeStatements(scope).slice(index)
+            ...NodeAppender.getScopeStatements(nodeWithStatements).slice(index)
         ]);
         ]);
     }
     }
 
 
     /**
     /**
-     * @param {TNodeWithScope} scope
+     * @param {TNodeWithStatements} nodeWithStatements
      * @param {TStatement[]} statements
      * @param {TStatement[]} statements
      */
      */
-    public static prepend (scope: TNodeWithScope, statements: TStatement[]): void {
-        statements = NodeAppender.parentizeScopeStatementsBeforeAppend(scope, statements);
+    public static prepend (nodeWithStatements: TNodeWithStatements, statements: TStatement[]): void {
+        statements = NodeAppender.parentizeScopeStatementsBeforeAppend(nodeWithStatements, statements);
 
 
-        NodeAppender.setScopeStatements(scope, [
+        NodeAppender.setScopeStatements(nodeWithStatements, [
             ...statements,
             ...statements,
-            ...NodeAppender.getScopeStatements(scope),
+            ...NodeAppender.getScopeStatements(nodeWithStatements),
         ]);
         ]);
     }
     }
 
 
     /**
     /**
-     * @param {TNodeWithScope} scope
+     * @param {TNodeWithStatements} nodeWithStatements
      * @returns {TStatement[]}
      * @returns {TStatement[]}
      */
      */
-    private static getScopeStatements (scope: TNodeWithScope): TStatement[] {
-        if (NodeGuards.isSwitchCaseNode(scope)) {
-            return scope.consequent;
+    private static getScopeStatements (nodeWithStatements: TNodeWithStatements): TStatement[] {
+        if (NodeGuards.isSwitchCaseNode(nodeWithStatements)) {
+            return nodeWithStatements.consequent;
         }
         }
 
 
-        return scope.body;
+        return nodeWithStatements.body;
     }
     }
 
 
     /**
     /**
-     * @param {TNodeWithScope} scope
+     * @param {TNodeWithStatements} nodeWithStatements
      * @param {TStatement[]} statements
      * @param {TStatement[]} statements
      * @returns {TStatement[]}
      * @returns {TStatement[]}
      */
      */
-    private static parentizeScopeStatementsBeforeAppend (scope: TNodeWithScope, statements: TStatement[]): TStatement[] {
+    private static parentizeScopeStatementsBeforeAppend (
+        nodeWithStatements: TNodeWithStatements,
+        statements: TStatement[]
+    ): TStatement[] {
         statements.forEach((statement: TStatement) => {
         statements.forEach((statement: TStatement) => {
-            statement.parentNode = scope;
+            statement.parentNode = nodeWithStatements;
         });
         });
 
 
         return statements;
         return statements;
     }
     }
 
 
     /**
     /**
-     * @param {TNodeWithScope} scope
+     * @param {TNodeWithStatements} nodeWithStatements
      * @param {TStatement[]} statements
      * @param {TStatement[]} statements
      */
      */
-    private static setScopeStatements (scope: TNodeWithScope, statements: TStatement[]): void {
-        if (NodeGuards.isSwitchCaseNode(scope)) {
-            scope.consequent = <ESTree.Statement[]>statements;
+    private static setScopeStatements (nodeWithStatements: TNodeWithStatements, statements: TStatement[]): void {
+        if (NodeGuards.isSwitchCaseNode(nodeWithStatements)) {
+            nodeWithStatements.consequent = <ESTree.Statement[]>statements;
 
 
             return;
             return;
         }
         }
 
 
-        scope.body = statements;
+        nodeWithStatements.body = statements;
     }
     }
 }
 }

+ 4 - 14
src/node/NodeFactory.ts

@@ -92,16 +92,11 @@ export class NodeFactory {
      * @returns {BreakStatement}
      * @returns {BreakStatement}
      */
      */
     public static breakStatement (label?: ESTree.Identifier): ESTree.BreakStatement {
     public static breakStatement (label?: ESTree.Identifier): ESTree.BreakStatement {
-        const breakStatementNode: ESTree.BreakStatement = {
+        return {
             type: NodeType.BreakStatement,
             type: NodeType.BreakStatement,
+            label,
             metadata: { ignoredNode: false }
             metadata: { ignoredNode: false }
         };
         };
-
-        if (label) {
-            breakStatementNode.label = label;
-        }
-
-        return breakStatementNode;
     }
     }
 
 
     /**
     /**
@@ -126,16 +121,11 @@ export class NodeFactory {
      * @returns {ContinueStatement}
      * @returns {ContinueStatement}
      */
      */
     public static continueStatement (label?: ESTree.Identifier): ESTree.ContinueStatement {
     public static continueStatement (label?: ESTree.Identifier): ESTree.ContinueStatement {
-        const continueStatementNode: ESTree.ContinueStatement = {
+        return {
             type: NodeType.ContinueStatement,
             type: NodeType.ContinueStatement,
+            label,
             metadata: { ignoredNode: false }
             metadata: { ignoredNode: false }
         };
         };
-
-        if (label) {
-            continueStatementNode.label = label;
-        }
-
-        return continueStatementNode;
     }
     }
 
 
     /**
     /**

+ 28 - 41
src/node/NodeGuards.ts

@@ -1,7 +1,7 @@
 import * as ESTree from 'estree';
 import * as ESTree from 'estree';
 
 
-import { TNodeWithBlockScope } from '../types/node/TNodeWithBlockScope';
-import { TNodeWithScope } from '../types/node/TNodeWithScope';
+import { TNodeWithLexicalScope } from '../types/node/TNodeWithLexicalScope';
+import { TNodeWithStatements } from '../types/node/TNodeWithStatements';
 
 
 import { NodeType } from '../enums/node/NodeType';
 import { NodeType } from '../enums/node/NodeType';
 
 
@@ -9,7 +9,7 @@ export class NodeGuards {
     /**
     /**
      * @type {string[]}
      * @type {string[]}
      */
      */
-    private static readonly nodesWithBlockScope: string[] = [
+    private static readonly nodesWithLexicalStatements: string[] = [
         NodeType.ArrowFunctionExpression,
         NodeType.ArrowFunctionExpression,
         NodeType.FunctionDeclaration,
         NodeType.FunctionDeclaration,
         NodeType.FunctionExpression,
         NodeType.FunctionExpression,
@@ -32,14 +32,6 @@ export class NodeGuards {
         return node.type === NodeType.ArrowFunctionExpression;
         return node.type === NodeType.ArrowFunctionExpression;
     }
     }
 
 
-    /**
-     * @param {Node} node
-     * @returns {boolean}
-     */
-    public static isAssignmentExpressionNode (node: ESTree.Node): node is ESTree.AssignmentExpression {
-        return node.type === NodeType.AssignmentExpression;
-    }
-
     /**
     /**
      * @param {Node} node
      * @param {Node} node
      * @returns {boolean}
      * @returns {boolean}
@@ -124,32 +116,34 @@ export class NodeGuards {
      * @param {Node} node
      * @param {Node} node
      * @returns {boolean}
      * @returns {boolean}
      */
      */
-    public static isFunctionDeclarationNode (node: ESTree.Node): node is ESTree.FunctionDeclaration {
-        return node.type === NodeType.FunctionDeclaration;
+    public static isFunctionNode (node: ESTree.Node): node is ESTree.Function {
+        return NodeGuards.isFunctionDeclarationNode(node) ||
+            NodeGuards.isFunctionExpressionNode(node) ||
+            NodeGuards.isArrowFunctionExpressionNode(node);
     }
     }
 
 
     /**
     /**
      * @param {Node} node
      * @param {Node} node
      * @returns {boolean}
      * @returns {boolean}
      */
      */
-    public static isFunctionExpressionNode (node: ESTree.Node): node is ESTree.FunctionExpression {
-        return node.type === NodeType.FunctionExpression;
+    public static isFunctionDeclarationNode (node: ESTree.Node): node is ESTree.FunctionDeclaration {
+        return node.type === NodeType.FunctionDeclaration;
     }
     }
 
 
     /**
     /**
      * @param {Node} node
      * @param {Node} node
      * @returns {boolean}
      * @returns {boolean}
      */
      */
-    public static isIdentifierNode (node: ESTree.Node): node is ESTree.Identifier {
-        return node.type === NodeType.Identifier;
+    public static isFunctionExpressionNode (node: ESTree.Node): node is ESTree.FunctionExpression {
+        return node.type === NodeType.FunctionExpression;
     }
     }
 
 
     /**
     /**
      * @param {Node} node
      * @param {Node} node
      * @returns {boolean}
      * @returns {boolean}
      */
      */
-    public static isIfStatementNode (node: ESTree.Node): node is ESTree.IfStatement {
-        return node.type === NodeType.IfStatement;
+    public static isIdentifierNode (node: ESTree.Node): node is ESTree.Identifier {
+        return node.type === NodeType.Identifier;
     }
     }
 
 
     /**
     /**
@@ -160,22 +154,6 @@ export class NodeGuards {
         return node.type === NodeType.ImportDeclaration;
         return node.type === NodeType.ImportDeclaration;
     }
     }
 
 
-    /**
-     * @param {Node} node
-     * @returns {boolean}
-     */
-    public static isImportDefaultSpecifierNode (node: ESTree.Node): node is ESTree.ImportDefaultSpecifier {
-        return node.type === NodeType.ImportDefaultSpecifier;
-    }
-
-    /**
-     * @param {Node} node
-     * @returns {boolean}
-     */
-    public static isImportNamespaceSpecifierNode (node: ESTree.Node): node is ESTree.ImportNamespaceSpecifier {
-        return node.type === NodeType.ImportNamespaceSpecifier;
-    }
-
     /**
     /**
      * @param {Node} node
      * @param {Node} node
      * @returns {boolean}
      * @returns {boolean}
@@ -237,23 +215,32 @@ export class NodeGuards {
         return object && !object.type !== undefined;
         return object && !object.type !== undefined;
     }
     }
 
 
+    /**
+     * @param {Node} node
+     * @returns {boolean}
+     */
+    public static isNodeWithLexicalScope (node: ESTree.Node): node is TNodeWithLexicalScope {
+        return NodeGuards.isProgramNode(node) || NodeGuards.isFunctionNode(node);
+    }
+
     /**
     /**
      * @param {Node} node
      * @param {Node} node
      * @param {Node} parentNode
      * @param {Node} parentNode
      * @returns {boolean}
      * @returns {boolean}
      */
      */
-    public static isNodeHasBlockScope (node: ESTree.Node, parentNode: ESTree.Node): node is TNodeWithBlockScope {
-        return NodeGuards.isProgramNode(node) || (
-            NodeGuards.isBlockStatementNode(node)
-            && NodeGuards.nodesWithBlockScope.includes(parentNode.type)
-        );
+    public static isNodeWithLexicalScopeStatements (
+        node: ESTree.Node,
+        parentNode: ESTree.Node
+    ): node is TNodeWithStatements {
+        return NodeGuards.isProgramNode(node)
+            || (NodeGuards.isBlockStatementNode(node) && NodeGuards.nodesWithLexicalStatements.includes(parentNode.type));
     }
     }
 
 
     /**
     /**
      * @param {Node} node
      * @param {Node} node
      * @returns {boolean}
      * @returns {boolean}
      */
      */
-    public static isNodeHasScope (node: ESTree.Node): node is TNodeWithScope {
+    public static isNodeWithStatements (node: ESTree.Node): node is TNodeWithStatements {
         return NodeGuards.isProgramNode(node)
         return NodeGuards.isProgramNode(node)
             || NodeGuards.isBlockStatementNode(node)
             || NodeGuards.isBlockStatementNode(node)
             || NodeGuards.isSwitchCaseNode(node);
             || NodeGuards.isSwitchCaseNode(node);

+ 57 - 0
src/node/NodeLexicalScopeUtils.ts

@@ -0,0 +1,57 @@
+import * as ESTree from 'estree';
+
+import { TNodeWithLexicalScope } from '../types/node/TNodeWithLexicalScope';
+
+import { NodeGuards } from './NodeGuards';
+
+export class NodeLexicalScopeUtils {
+    /**
+     * @param {Node} node
+     * @returns {TNodeWithLexicalScope}
+     */
+    public static getLexicalScope (node: ESTree.Node): TNodeWithLexicalScope | undefined {
+        return NodeLexicalScopeUtils.getLexicalScopesRecursive(node, 1)[0];
+    }
+
+    /**
+     * @param {Node} node
+     * @returns {TNodeWithLexicalScope[]}
+     */
+    public static getLexicalScopes (node: ESTree.Node): TNodeWithLexicalScope[] {
+        return NodeLexicalScopeUtils.getLexicalScopesRecursive(node);
+    }
+
+    /***
+     * @param {Node} node
+     * @param {number} maxSize
+     * @param {TNodeWithLexicalScope[]} nodesWithLexicalScope
+     * @param {number} depth
+     * @returns {TNodeWithLexicalScope[]}
+     */
+    private static getLexicalScopesRecursive (
+        node: ESTree.Node,
+        maxSize: number = Infinity,
+        nodesWithLexicalScope: TNodeWithLexicalScope[] = [],
+        depth: number = 0
+    ): TNodeWithLexicalScope[] {
+        if (nodesWithLexicalScope.length >= maxSize) {
+            return nodesWithLexicalScope;
+        }
+
+        const parentNode: ESTree.Node | undefined = node.parentNode;
+
+        if (!parentNode) {
+            throw new ReferenceError('`parentNode` property of given node is `undefined`');
+        }
+
+        if (NodeGuards.isNodeWithLexicalScope(node)) {
+            nodesWithLexicalScope.push(node);
+        }
+
+        if (node !== parentNode) {
+            return NodeLexicalScopeUtils.getLexicalScopesRecursive(parentNode, maxSize, nodesWithLexicalScope, ++depth);
+        }
+
+        return nodesWithLexicalScope;
+    }
+}

+ 135 - 0
src/node/NodeStatementUtils.ts

@@ -0,0 +1,135 @@
+import * as ESTree from 'estree';
+
+import { TNodeWithStatements } from '../types/node/TNodeWithStatements';
+import { TStatement } from '../types/node/TStatement';
+
+import { NodeGuards } from './NodeGuards';
+
+export class NodeStatementUtils {
+    /**
+     * @param {Node} node
+     * @returns {TNodeWithStatements}
+     */
+    public static getParentNodeWithStatements (node: ESTree.Node): TNodeWithStatements {
+        return NodeStatementUtils.getParentNodesWithStatementsRecursive(node, 1)[0];
+    }
+
+    /**
+     * @param {Node} node
+     * @returns {TNodeWithStatements[]}
+     */
+    public static getParentNodesWithStatements (node: ESTree.Node): TNodeWithStatements[] {
+        return NodeStatementUtils.getParentNodesWithStatementsRecursive(node);
+    }
+
+    /**
+     * @param {Statement} statement
+     * @returns {TStatement | null}
+     */
+    public static getNextSiblingStatement (statement: ESTree.Statement): TStatement | null {
+        return NodeStatementUtils.getSiblingStatementByOffset(statement, 1);
+    }
+
+    /**
+     * @param {Statement} statement
+     * @returns {TStatement | null}
+     */
+    public static getPreviousSiblingStatement (statement: ESTree.Statement): TStatement | null {
+        return NodeStatementUtils.getSiblingStatementByOffset(statement, -1);
+    }
+
+    /**
+     * @param {Node} node
+     * @returns {Statement}
+     */
+    public static getRootStatementOfNode (node: ESTree.Node): ESTree.Statement {
+        if (NodeGuards.isProgramNode(node)) {
+            throw new Error('Unable to find root statement for `Program` node');
+        }
+
+        const parentNode: ESTree.Node | undefined = node.parentNode;
+
+        if (!parentNode) {
+            throw new ReferenceError('`parentNode` property of given node is `undefined`');
+        }
+
+        if (!NodeGuards.isNodeWithStatements(parentNode)) {
+            return NodeStatementUtils.getRootStatementOfNode(parentNode);
+        }
+
+        return <ESTree.Statement>node;
+    }
+
+    /**
+     * @param {NodeGuards} node
+     * @returns {TNodeWithStatements}
+     */
+    public static getScopeOfNode (node: ESTree.Node): TNodeWithStatements {
+        const parentNode: ESTree.Node | undefined = node.parentNode;
+
+        if (!parentNode) {
+            throw new ReferenceError('`parentNode` property of given node is `undefined`');
+        }
+
+        if (!NodeGuards.isNodeWithStatements(parentNode)) {
+            return NodeStatementUtils.getScopeOfNode(parentNode);
+        }
+
+        return parentNode;
+    }
+
+    /***
+     * @param {Node} node
+     * @param {number} maxSize
+     * @param {TNodeWithStatements[]} nodesWithStatements
+     * @param {number} depth
+     * @returns {TNodeWithStatements[]}
+     */
+    private static getParentNodesWithStatementsRecursive (
+        node: ESTree.Node,
+        maxSize: number = Infinity,
+        nodesWithStatements: TNodeWithStatements[] = [],
+        depth: number = 0
+    ): TNodeWithStatements[] {
+        if (nodesWithStatements.length >= maxSize) {
+            return nodesWithStatements;
+        }
+
+        const parentNode: ESTree.Node | undefined = node.parentNode;
+
+        if (!parentNode) {
+            throw new ReferenceError('`parentNode` property of given node is `undefined`');
+        }
+
+        if (
+            /**
+             * we can add program node instantly
+             */
+            NodeGuards.isProgramNode(node) ||
+            (NodeGuards.isNodeWithLexicalScopeStatements(node, parentNode) && depth > 0)
+        ) {
+            nodesWithStatements.push(node);
+        }
+
+        if (node !== parentNode) {
+            return NodeStatementUtils.getParentNodesWithStatementsRecursive(parentNode, maxSize, nodesWithStatements, ++depth);
+        }
+
+        return nodesWithStatements;
+    }
+
+    /**
+     * @param {Statement} statement
+     * @param {number} offset
+     * @returns {TStatement | null}
+     */
+    private static getSiblingStatementByOffset (statement: ESTree.Statement, offset: number): TStatement | null {
+        const scopeNode: TNodeWithStatements = NodeStatementUtils.getScopeOfNode(statement);
+        const scopeBody: TStatement[] = !NodeGuards.isSwitchCaseNode(scopeNode)
+            ? scopeNode.body
+            : scopeNode.consequent;
+        const indexInScope: number = scopeBody.indexOf(statement);
+
+        return scopeBody[indexInScope + offset] || null;
+    }
+}

+ 0 - 144
src/node/NodeUtils.ts

@@ -3,10 +3,7 @@ import * as espree from 'espree';
 import * as estraverse from 'estraverse';
 import * as estraverse from 'estraverse';
 import * as ESTree from 'estree';
 import * as ESTree from 'estree';
 
 
-import { TNodeWithBlockScope } from '../types/node/TNodeWithBlockScope';
-import { TNodeWithScope } from '../types/node/TNodeWithScope';
 import { TObject } from '../types/TObject';
 import { TObject } from '../types/TObject';
-import { TStatement } from '../types/node/TStatement';
 
 
 import { NodeGuards } from './NodeGuards';
 import { NodeGuards } from './NodeGuards';
 import { NodeMetadata } from './NodeMetadata';
 import { NodeMetadata } from './NodeMetadata';
@@ -69,78 +66,6 @@ export class NodeUtils {
         }, '');
         }, '');
     }
     }
 
 
-    /**
-     * @param {Node} node
-     * @returns {TNodeWithBlockScope}
-     */
-    public static getBlockScopeOfNode (node: ESTree.Node): TNodeWithBlockScope {
-        return NodeUtils.getBlockScopesOfNodeRecursive(node, 1)[0];
-    }
-
-    /**
-     * @param {Node} node
-     * @returns {TNodeWithBlockScope[]}
-     */
-    public static getBlockScopesOfNode (node: ESTree.Node): TNodeWithBlockScope[] {
-        return NodeUtils.getBlockScopesOfNodeRecursive(node);
-    }
-
-    /**
-     * @param {Statement} statement
-     * @returns {TStatement | null}
-     */
-    public static getNextSiblingStatement (statement: ESTree.Statement): TStatement | null {
-        return NodeUtils.getSiblingStatementByOffset(statement, 1);
-    }
-
-    /**
-     * @param {Statement} statement
-     * @returns {TStatement | null}
-     */
-    public static getPreviousSiblingStatement (statement: ESTree.Statement): TStatement | null {
-        return NodeUtils.getSiblingStatementByOffset(statement, -1);
-    }
-
-    /**
-     * @param {Node} node
-     * @returns {Statement}
-     */
-    public static getRootStatementOfNode (node: ESTree.Node): ESTree.Statement {
-        if (NodeGuards.isProgramNode(node)) {
-            throw new Error('Unable to find root statement for `Program` node');
-        }
-
-        const parentNode: ESTree.Node | undefined = node.parentNode;
-
-        if (!parentNode) {
-            throw new ReferenceError('`parentNode` property of given node is `undefined`');
-        }
-
-        if (!NodeGuards.isNodeHasScope(parentNode)) {
-            return NodeUtils.getRootStatementOfNode(parentNode);
-        }
-
-        return <ESTree.Statement>node;
-    }
-
-    /**
-     * @param {NodeGuards} node
-     * @returns {TNodeWithScope}
-     */
-    public static getScopeOfNode (node: ESTree.Node): TNodeWithScope {
-        const parentNode: ESTree.Node | undefined = node.parentNode;
-
-        if (!parentNode) {
-            throw new ReferenceError('`parentNode` property of given node is `undefined`');
-        }
-
-        if (!NodeGuards.isNodeHasScope(parentNode)) {
-            return NodeUtils.getScopeOfNode(parentNode);
-        }
-
-        return parentNode;
-    }
-
     /**
     /**
      * @param {UnaryExpression} unaryExpressionNode
      * @param {UnaryExpression} unaryExpressionNode
      * @returns {NodeGuards}
      * @returns {NodeGuards}
@@ -213,73 +138,4 @@ export class NodeUtils {
 
 
         return <T>copy;
         return <T>copy;
     }
     }
-
-    /***
-     * @param {Node} node
-     * @param {number} maxSize
-     * @param {TNodeWithBlockScope[]} blockScopes
-     * @param {number} depth
-     * @returns {TNodeWithBlockScope[]}
-     */
-    private static getBlockScopesOfNodeRecursive (
-        node: ESTree.Node,
-        maxSize: number = Infinity,
-        blockScopes: TNodeWithBlockScope[] = [],
-        depth: number = 0
-    ): TNodeWithBlockScope[] {
-        if (blockScopes.length >= maxSize) {
-            return blockScopes;
-        }
-
-        const parentNode: ESTree.Node | undefined = node.parentNode;
-
-        if (!parentNode) {
-            throw new ReferenceError('`parentNode` property of given node is `undefined`');
-        }
-
-        /**
-         * Stage 1: process root block statement node of the slice of AST-tree
-         */
-        if (NodeGuards.isBlockStatementNode(node) && parentNode === node) {
-            blockScopes.push(node);
-        }
-
-        /**
-         * Stage 2: process any other nodes
-         */
-        if (
-            /**
-             * we can add program node instantly
-             */
-            NodeGuards.isProgramNode(node) ||
-            /**
-             * we shouldn't add to the array input node that is node with block scope itself
-             * so, on depth 0 we will skip push to the array of block scopes
-             */
-            (depth && NodeGuards.isNodeHasBlockScope(node, parentNode))
-        ) {
-            blockScopes.push(node);
-        }
-
-        if (node !== parentNode) {
-            return NodeUtils.getBlockScopesOfNodeRecursive(parentNode, maxSize, blockScopes, ++depth);
-        }
-
-        return blockScopes;
-    }
-
-    /**
-     * @param {Statement} statement
-     * @param {number} offset
-     * @returns {TStatement | null}
-     */
-    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(statement);
-
-        return scopeBody[indexInScope + offset] || null;
-    }
 }
 }

+ 41 - 27
src/source-map/SourceMapCorrector.ts → src/source-code/ObfuscatedCode.ts

@@ -1,26 +1,25 @@
 import { inject, injectable } from 'inversify';
 import { inject, injectable } from 'inversify';
 import { ServiceIdentifiers } from '../container/ServiceIdentifiers';
 import { ServiceIdentifiers } from '../container/ServiceIdentifiers';
 
 
-import { TObfuscationResultFactory } from '../types/container/TObfuscationResultFactory';
-
 import { ICryptUtils } from '../interfaces/utils/ICryptUtils';
 import { ICryptUtils } from '../interfaces/utils/ICryptUtils';
-import { IObfuscationResult } from '../interfaces/IObfuscationResult';
-import { IOptions } from '../interfaces/options/IOptions';
-import { ISourceMapCorrector } from '../interfaces/source-map/ISourceMapCorrector';
+import { IObfuscatedCode } from '../interfaces/source-code/IObfuscatedCode';
 
 
+import { initializable } from '../decorators/Initializable';
 import { SourceMapMode } from '../enums/source-map/SourceMapMode';
 import { SourceMapMode } from '../enums/source-map/SourceMapMode';
+import { IOptions } from '../interfaces/options/IOptions';
 
 
 @injectable()
 @injectable()
-export class SourceMapCorrector implements ISourceMapCorrector {
+export class ObfuscatedCode implements IObfuscatedCode {
     /**
     /**
      * @type {ICryptUtils}
      * @type {ICryptUtils}
      */
      */
     private readonly cryptUtils: ICryptUtils;
     private readonly cryptUtils: ICryptUtils;
 
 
     /**
     /**
-     * @type {TObfuscationResultFactory}
+     * @type {string}
      */
      */
-    private readonly obfuscationResultFactory: TObfuscationResultFactory;
+    @initializable()
+    private obfuscatedCode!: string;
 
 
     /**
     /**
      * @type {IOptions}
      * @type {IOptions}
@@ -28,16 +27,15 @@ export class SourceMapCorrector implements ISourceMapCorrector {
     private readonly options: IOptions;
     private readonly options: IOptions;
 
 
     /**
     /**
-     * @param {TObfuscationResultFactory} obfuscationResultFactory
-     * @param {ICryptUtils} cryptUtils
-     * @param {IOptions} options
+     * @type {string}
      */
      */
+    @initializable()
+    private sourceMap!: string;
+
     constructor (
     constructor (
-        @inject(ServiceIdentifiers.Factory__IObfuscationResult) obfuscationResultFactory: TObfuscationResultFactory,
         @inject(ServiceIdentifiers.ICryptUtils) cryptUtils: ICryptUtils,
         @inject(ServiceIdentifiers.ICryptUtils) cryptUtils: ICryptUtils,
         @inject(ServiceIdentifiers.IOptions) options: IOptions
         @inject(ServiceIdentifiers.IOptions) options: IOptions
     ) {
     ) {
-        this.obfuscationResultFactory = obfuscationResultFactory;
         this.cryptUtils = cryptUtils;
         this.cryptUtils = cryptUtils;
         this.options = options;
         this.options = options;
     }
     }
@@ -45,23 +43,39 @@ export class SourceMapCorrector implements ISourceMapCorrector {
     /**
     /**
      * @param {string} obfuscatedCode
      * @param {string} obfuscatedCode
      * @param {string} sourceMap
      * @param {string} sourceMap
-     * @returns {IObfuscationResult}
      */
      */
-    public correct (obfuscatedCode: string, sourceMap: string): IObfuscationResult {
-        return this.obfuscationResultFactory(
-            this.correctObfuscatedCode(obfuscatedCode, sourceMap),
-            sourceMap
-        );
+    public initialize (obfuscatedCode: string, sourceMap: string): void {
+        this.obfuscatedCode = obfuscatedCode;
+        this.sourceMap = sourceMap;
+    }
+
+    /**
+     * @returns {string}
+     */
+    public getObfuscatedCode (): string {
+        return this.correctObfuscatedCode();
+    }
+
+    /**
+     * @returns {string}
+     */
+    public getSourceMap (): string {
+        return this.sourceMap;
+    }
+
+    /**
+     * @returns {string}
+     */
+    public toString (): string {
+        return this.obfuscatedCode;
     }
     }
 
 
     /**
     /**
-     * @param {string} obfuscatedCode
-     * @param {string} sourceMap
      * @returns {string}
      * @returns {string}
      */
      */
-    private correctObfuscatedCode (obfuscatedCode: string, sourceMap: string): string {
-        if (!sourceMap) {
-            return obfuscatedCode;
+    private correctObfuscatedCode (): string {
+        if (!this.sourceMap) {
+            return this.obfuscatedCode;
         }
         }
 
 
         const sourceMapUrl: string = this.options.sourceMapBaseUrl + this.options.sourceMapFileName;
         const sourceMapUrl: string = this.options.sourceMapBaseUrl + this.options.sourceMapFileName;
@@ -70,19 +84,19 @@ export class SourceMapCorrector implements ISourceMapCorrector {
 
 
         switch (this.options.sourceMapMode) {
         switch (this.options.sourceMapMode) {
             case SourceMapMode.Inline:
             case SourceMapMode.Inline:
-                sourceMappingUrl += `data:application/json;base64,${this.cryptUtils.btoa(sourceMap)}`;
+                sourceMappingUrl += `data:application/json;base64,${this.cryptUtils.btoa(this.sourceMap)}`;
 
 
                 break;
                 break;
 
 
             case SourceMapMode.Separate:
             case SourceMapMode.Separate:
             default:
             default:
                 if (!sourceMapUrl) {
                 if (!sourceMapUrl) {
-                    return obfuscatedCode;
+                    return this.obfuscatedCode;
                 }
                 }
 
 
                 sourceMappingUrl += sourceMapUrl;
                 sourceMappingUrl += sourceMapUrl;
         }
         }
 
 
-        return `${obfuscatedCode}\n${sourceMappingUrl}`;
+        return `${this.obfuscatedCode}\n${sourceMappingUrl}`;
     }
     }
 }
 }

+ 43 - 0
src/source-code/SourceCode.ts

@@ -0,0 +1,43 @@
+import { ISourceCode } from '../interfaces/source-code/ISourceCode';
+
+export class SourceCode implements ISourceCode {
+    /**
+     * @type {string}
+     */
+    private readonly sourceCode: string;
+
+    /**
+     * @type {string}
+     */
+    private readonly sourceMap: string;
+
+    /**
+     * @param {string} sourceCode
+     * @param {string} sourceMap
+     */
+    constructor (sourceCode: string, sourceMap: string) {
+        this.sourceCode = sourceCode;
+        this.sourceMap = sourceMap;
+    }
+
+    /**
+     * @returns {string}
+     */
+    public getSourceCode (): string {
+        return this.sourceCode;
+    }
+
+    /**
+     * @returns {string}
+     */
+    public getSourceMap (): string {
+        return this.sourceMap;
+    }
+
+    /**
+     * @returns {string}
+     */
+    public toString (): string {
+        return this.sourceCode;
+    }
+}

+ 1 - 1
src/types/TObject.d.ts

@@ -1,3 +1,3 @@
 /* tslint:disable:interface-over-type-literal */
 /* tslint:disable:interface-over-type-literal */
 
 
-export type TObject <T = any> = {[key: string]: T};
+export type TObject <T = unknown> = {[key: string]: T};

+ 0 - 3
src/types/container/TObfuscationResultFactory.d.ts

@@ -1,3 +0,0 @@
-import { IObfuscationResult } from '../../interfaces/IObfuscationResult';
-
-export type TObfuscationResultFactory = (obfuscatedCode: string, sourceMap: string) => IObfuscationResult;

+ 3 - 0
src/types/container/source-code/TObfuscatedCodeFactory.d.ts

@@ -0,0 +1,3 @@
+import { IObfuscatedCode } from '../../../interfaces/source-code/IObfuscatedCode';
+
+export type TObfuscatedCodeFactory = (obfuscatedCode: string, sourceMap: string) => IObfuscatedCode;

+ 0 - 3
src/types/node/TNodeWithBlockScope.d.ts

@@ -1,3 +0,0 @@
-import * as ESTree from 'estree';
-
-export type TNodeWithBlockScope = ESTree.Program | ESTree.BlockStatement;

+ 3 - 0
src/types/node/TNodeWithLexicalScope.d.ts

@@ -0,0 +1,3 @@
+import * as ESTree from 'estree';
+
+export type TNodeWithLexicalScope = ESTree.Program | ESTree.Function;

+ 0 - 3
src/types/node/TNodeWithScope.d.ts

@@ -1,3 +0,0 @@
-import * as ESTree from 'estree';
-
-export type TNodeWithScope = ESTree.Program | ESTree.BlockStatement | ESTree.SwitchCase;

+ 3 - 0
src/types/node/TNodeWithStatements.d.ts

@@ -0,0 +1,3 @@
+import * as ESTree from 'estree';
+
+export type TNodeWithStatements = ESTree.Program | ESTree.BlockStatement | ESTree.SwitchCase;

+ 0 - 1
src/types/source-map/TSourceMapMode.d.ts

@@ -1 +0,0 @@
-export type TSourceMapMode = 'inline' | 'separate';

+ 1 - 14
src/utils/RandomGenerator.ts

@@ -7,7 +7,7 @@ import { Chance } from 'chance';
 import { IInitializable } from '../interfaces/IInitializable';
 import { IInitializable } from '../interfaces/IInitializable';
 import { IOptions } from '../interfaces/options/IOptions';
 import { IOptions } from '../interfaces/options/IOptions';
 import { IRandomGenerator } from '../interfaces/utils/IRandomGenerator';
 import { IRandomGenerator } from '../interfaces/utils/IRandomGenerator';
-import { ISourceCode } from '../interfaces/ISourceCode';
+import { ISourceCode } from '../interfaces/source-code/ISourceCode';
 
 
 import { initializable } from '../decorators/Initializable';
 import { initializable } from '../decorators/Initializable';
 
 
@@ -81,19 +81,6 @@ export class RandomGenerator implements IRandomGenerator, IInitializable {
         return this.getRandomInteger(0, 99999) / 100000;
         return this.getRandomInteger(0, 99999) / 100000;
     }
     }
 
 
-    /**
-     * @param {number} min
-     * @param {number} max
-     * @returns {number}
-     */
-    public getRandomFloat (min: number, max: number): number {
-        return this.getRandomGenerator().floating({
-            min: min,
-            max: max,
-            fixed: 7
-        });
-    }
-
     /**
     /**
      * @returns {Chance.Chance}
      * @returns {Chance.Chance}
      */
      */

+ 2 - 5
test/dev/dev.ts

@@ -6,11 +6,8 @@ import { NO_ADDITIONAL_NODES_PRESET } from '../../src/options/presets/NoCustomNo
 
 
     let obfuscatedCode: string = JavaScriptObfuscator.obfuscate(
     let obfuscatedCode: string = JavaScriptObfuscator.obfuscate(
         `
         `
-        (function () {
-            let a = 0;
-            let b = 0;
-            var test = {a, b};
-        })();
+        const foo = 1;
+        [].map(foo=>1).map(bar=>[foo]);
         `,
         `,
         {
         {
             ...NO_ADDITIONAL_NODES_PRESET,
             ...NO_ADDITIONAL_NODES_PRESET,

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

@@ -7,7 +7,7 @@ import * as ESTree from 'estree';
 
 
 import { assert } from 'chai';
 import { assert } from 'chai';
 
 
-import { TNodeWithBlockScope } from '../../../../src/types/node/TNodeWithBlockScope';
+import { TNodeWithStatements } from '../../../../src/types/node/TNodeWithStatements';
 
 
 import { IInversifyContainerFacade } from '../../../../src/interfaces/container/IInversifyContainerFacade';
 import { IInversifyContainerFacade } from '../../../../src/interfaces/container/IInversifyContainerFacade';
 import { IStackTraceAnalyzer } from '../../../../src/interfaces/analyzers/stack-trace-analyzer/IStackTraceAnalyzer';
 import { IStackTraceAnalyzer } from '../../../../src/interfaces/analyzers/stack-trace-analyzer/IStackTraceAnalyzer';
@@ -157,7 +157,7 @@ describe('StackTraceAnalyzer', () => {
         before(() => {
         before(() => {
             const inversifyContainerFacade: IInversifyContainerFacade = new InversifyContainerFacade();
             const inversifyContainerFacade: IInversifyContainerFacade = new InversifyContainerFacade();
 
 
-            inversifyContainerFacade.load('', {});
+            inversifyContainerFacade.load('', '', {});
             stackTraceAnalyzer = inversifyContainerFacade
             stackTraceAnalyzer = inversifyContainerFacade
                 .get<IStackTraceAnalyzer>(ServiceIdentifiers.IStackTraceAnalyzer);
                 .get<IStackTraceAnalyzer>(ServiceIdentifiers.IStackTraceAnalyzer);
         });
         });
@@ -165,7 +165,7 @@ describe('StackTraceAnalyzer', () => {
         describe('Variant #1: basic-1', () => {
         describe('Variant #1: basic-1', () => {
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/basic-1.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/basic-1.js');
-                const astTree: TNodeWithBlockScope = NodeFactory.programNode(
+                const astTree: TNodeWithStatements = NodeFactory.programNode(
                     NodeUtils.convertCodeToStructure(code)
                     NodeUtils.convertCodeToStructure(code)
                 );
                 );
 
 
@@ -215,7 +215,7 @@ describe('StackTraceAnalyzer', () => {
         describe('Variant #2: basic-2', () => {
         describe('Variant #2: basic-2', () => {
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/basic-2.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/basic-2.js');
-                const astTree: TNodeWithBlockScope = NodeFactory.programNode(
+                const astTree: TNodeWithStatements = NodeFactory.programNode(
                     NodeUtils.convertCodeToStructure(code)
                     NodeUtils.convertCodeToStructure(code)
                 );
                 );
 
 
@@ -254,7 +254,7 @@ describe('StackTraceAnalyzer', () => {
         describe('Variant #3: deep conditions nesting', () => {
         describe('Variant #3: deep conditions nesting', () => {
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/deep-conditions-nesting.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/deep-conditions-nesting.js');
-                const astTree: TNodeWithBlockScope = NodeFactory.programNode(
+                const astTree: TNodeWithStatements = NodeFactory.programNode(
                     NodeUtils.convertCodeToStructure(code)
                     NodeUtils.convertCodeToStructure(code)
                 );
                 );
 
 
@@ -293,7 +293,7 @@ describe('StackTraceAnalyzer', () => {
         describe('Variant #4: call before declaration', () => {
         describe('Variant #4: call before declaration', () => {
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/call-before-declaration.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/call-before-declaration.js');
-                const astTree: TNodeWithBlockScope = NodeFactory.programNode(
+                const astTree: TNodeWithStatements = NodeFactory.programNode(
                     NodeUtils.convertCodeToStructure(code)
                     NodeUtils.convertCodeToStructure(code)
                 );
                 );
 
 
@@ -316,7 +316,7 @@ describe('StackTraceAnalyzer', () => {
         describe('Variant #5: call expression of object member #1', () => {
         describe('Variant #5: call expression of object member #1', () => {
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/call-expression-of-object-member-1.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/call-expression-of-object-member-1.js');
-                const astTree: TNodeWithBlockScope = NodeFactory.programNode(
+                const astTree: TNodeWithStatements = NodeFactory.programNode(
                     NodeUtils.convertCodeToStructure(code)
                     NodeUtils.convertCodeToStructure(code)
                 );
                 );
 
 
@@ -375,7 +375,7 @@ describe('StackTraceAnalyzer', () => {
         describe('Variant #5: call expression of object member #2', () => {
         describe('Variant #5: call expression of object member #2', () => {
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/call-expression-of-object-member-2.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/call-expression-of-object-member-2.js');
-                const astTree: TNodeWithBlockScope = NodeFactory.programNode(
+                const astTree: TNodeWithStatements = NodeFactory.programNode(
                     NodeUtils.convertCodeToStructure(code)
                     NodeUtils.convertCodeToStructure(code)
                 );
                 );
 
 
@@ -403,7 +403,7 @@ describe('StackTraceAnalyzer', () => {
         describe('Variant #6: no call expressions', () => {
         describe('Variant #6: no call expressions', () => {
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/no-call-expressions.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/no-call-expressions.js');
-                const astTree: TNodeWithBlockScope = NodeFactory.programNode(
+                const astTree: TNodeWithStatements = NodeFactory.programNode(
                     NodeUtils.convertCodeToStructure(code)
                     NodeUtils.convertCodeToStructure(code)
                 );
                 );
 
 
@@ -420,7 +420,7 @@ describe('StackTraceAnalyzer', () => {
         describe('Variant #7: only call expression', () => {
         describe('Variant #7: only call expression', () => {
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/only-call-expression.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/only-call-expression.js');
-                const astTree: TNodeWithBlockScope = NodeFactory.programNode(
+                const astTree: TNodeWithStatements = NodeFactory.programNode(
                     NodeUtils.convertCodeToStructure(code)
                     NodeUtils.convertCodeToStructure(code)
                 );
                 );
 
 
@@ -437,7 +437,7 @@ describe('StackTraceAnalyzer', () => {
         describe('Variant #8: self-invoking functions', () => {
         describe('Variant #8: self-invoking functions', () => {
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/self-invoking-functions.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/self-invoking-functions.js');
-                const astTree: TNodeWithBlockScope = NodeFactory.programNode(
+                const astTree: TNodeWithStatements = NodeFactory.programNode(
                     NodeUtils.convertCodeToStructure(code)
                     NodeUtils.convertCodeToStructure(code)
                 );
                 );
 
 
@@ -472,7 +472,7 @@ describe('StackTraceAnalyzer', () => {
         describe('Variant #9: no recursion', () => {
         describe('Variant #9: no recursion', () => {
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/no-recursion.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/no-recursion.js');
-                const astTree: TNodeWithBlockScope = NodeFactory.programNode(
+                const astTree: TNodeWithStatements = NodeFactory.programNode(
                     NodeUtils.convertCodeToStructure(code)
                     NodeUtils.convertCodeToStructure(code)
                 );
                 );
 
 

+ 6 - 10
test/functional-tests/custom-nodes/console-output-nodes/ConsoleOutputDisableExpressionNode.spec.ts

@@ -1,7 +1,5 @@
 import { assert } from 'chai';
 import { assert } from 'chai';
 
 
-import { IObfuscationResult } from '../../../../src/interfaces/IObfuscationResult';
-
 import { NO_ADDITIONAL_NODES_PRESET } from '../../../../src/options/presets/NoCustomNodes';
 import { NO_ADDITIONAL_NODES_PRESET } from '../../../../src/options/presets/NoCustomNodes';
 
 
 import { readFileAsString } from '../../../helpers/readFileAsString';
 import { readFileAsString } from '../../../helpers/readFileAsString';
@@ -18,15 +16,14 @@ describe('ConsoleOutputDisableExpressionNode', () => {
 
 
         before(() => {
         before(() => {
             const code: string = readFileAsString(__dirname + '/fixtures/simple-input.js');
             const code: string = readFileAsString(__dirname + '/fixtures/simple-input.js');
-            const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+            obfuscatedCode = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET,
                     ...NO_ADDITIONAL_NODES_PRESET,
                     disableConsoleOutput: true
                     disableConsoleOutput: true
                 }
                 }
-            );
-
-            obfuscatedCode = obfuscationResult.getObfuscatedCode();
+            ).getObfuscatedCode();
         });
         });
 
 
         it('match #1: should correctly append custom node into the obfuscated code', () => {
         it('match #1: should correctly append custom node into the obfuscated code', () => {
@@ -47,15 +44,14 @@ describe('ConsoleOutputDisableExpressionNode', () => {
 
 
         before(() => {
         before(() => {
             const code: string = readFileAsString(__dirname + '/fixtures/simple-input.js');
             const code: string = readFileAsString(__dirname + '/fixtures/simple-input.js');
-            const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+            obfuscatedCode = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET,
                     ...NO_ADDITIONAL_NODES_PRESET,
                     disableConsoleOutput: false
                     disableConsoleOutput: false
                 }
                 }
-            );
-
-            obfuscatedCode = obfuscationResult.getObfuscatedCode();
+            ).getObfuscatedCode();
         });
         });
 
 
         it('match #1: shouldn\'t append custom node into the obfuscated code', () => {
         it('match #1: shouldn\'t append custom node into the obfuscated code', () => {

+ 6 - 10
test/functional-tests/custom-nodes/domain-lock-nodes/DomainLockNode.spec.ts

@@ -1,7 +1,5 @@
 import { assert } from 'chai';
 import { assert } from 'chai';
 
 
-import { IObfuscationResult } from '../../../../src/interfaces/IObfuscationResult';
-
 import { NO_ADDITIONAL_NODES_PRESET } from '../../../../src/options/presets/NoCustomNodes';
 import { NO_ADDITIONAL_NODES_PRESET } from '../../../../src/options/presets/NoCustomNodes';
 
 
 import { readFileAsString } from '../../../helpers/readFileAsString';
 import { readFileAsString } from '../../../helpers/readFileAsString';
@@ -16,15 +14,14 @@ describe('DomainLockNode', () => {
 
 
         before(() => {
         before(() => {
             const code: string = readFileAsString(__dirname + '/fixtures/simple-input.js');
             const code: string = readFileAsString(__dirname + '/fixtures/simple-input.js');
-            const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+            obfuscatedCode = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET,
                     ...NO_ADDITIONAL_NODES_PRESET,
                     domainLock: ['.example.com']
                     domainLock: ['.example.com']
                 }
                 }
-            );
-
-            obfuscatedCode = obfuscationResult.getObfuscatedCode();
+            ).getObfuscatedCode();
         });
         });
 
 
         it('should correctly append custom node into the obfuscated code', () => {
         it('should correctly append custom node into the obfuscated code', () => {
@@ -37,15 +34,14 @@ describe('DomainLockNode', () => {
 
 
         before(() => {
         before(() => {
             const code: string = readFileAsString(__dirname + '/fixtures/simple-input.js');
             const code: string = readFileAsString(__dirname + '/fixtures/simple-input.js');
-            const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+            obfuscatedCode = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET,
                     ...NO_ADDITIONAL_NODES_PRESET,
                     domainLock: []
                     domainLock: []
                 }
                 }
-            );
-
-            obfuscatedCode = obfuscationResult.getObfuscatedCode();
+            ).getObfuscatedCode();
         });
         });
 
 
         it('shouldn\'t append custom node into the obfuscated code', () => {
         it('shouldn\'t append custom node into the obfuscated code', () => {

+ 4 - 10
test/functional-tests/custom-nodes/string-array-nodes/StringArrayCallsWrapper.spec.ts

@@ -1,7 +1,5 @@
 import { assert } from 'chai';
 import { assert } from 'chai';
 
 
-import { IObfuscationResult } from '../../../../src/interfaces/IObfuscationResult';
-
 import { NO_ADDITIONAL_NODES_PRESET } from '../../../../src/options/presets/NoCustomNodes';
 import { NO_ADDITIONAL_NODES_PRESET } from '../../../../src/options/presets/NoCustomNodes';
 
 
 import { readFileAsString } from '../../../helpers/readFileAsString';
 import { readFileAsString } from '../../../helpers/readFileAsString';
@@ -17,16 +15,14 @@ describe('StringArrayCallsWrapper', () => {
         before(() => {
         before(() => {
             const code: string = readFileAsString(__dirname + '/fixtures/simple-input.js');
             const code: string = readFileAsString(__dirname + '/fixtures/simple-input.js');
 
 
-            let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+            obfuscatedCode = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET,
                     ...NO_ADDITIONAL_NODES_PRESET,
                     stringArray: true,
                     stringArray: true,
                     stringArrayThreshold: 1
                     stringArrayThreshold: 1
                 }
                 }
-            );
-
-            obfuscatedCode = obfuscationResult.getObfuscatedCode();
+            ).getObfuscatedCode();
         });
         });
 
 
         it('should correctly append custom node into the obfuscated code', () => {
         it('should correctly append custom node into the obfuscated code', () => {
@@ -40,15 +36,13 @@ describe('StringArrayCallsWrapper', () => {
         before(() => {
         before(() => {
             const code: string = readFileAsString(__dirname + '/fixtures/simple-input.js');
             const code: string = readFileAsString(__dirname + '/fixtures/simple-input.js');
 
 
-            let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+            obfuscatedCode = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET,
                     ...NO_ADDITIONAL_NODES_PRESET,
                     stringArray: false
                     stringArray: false
                 }
                 }
-            );
-
-            obfuscatedCode = obfuscationResult.getObfuscatedCode();
+            ).getObfuscatedCode();
         });
         });
 
 
         it('shouldn\'t append custom node into the obfuscated code', () => {
         it('shouldn\'t append custom node into the obfuscated code', () => {

+ 4 - 10
test/functional-tests/custom-nodes/string-array-nodes/StringArrayNode.spec.ts

@@ -1,7 +1,5 @@
 import { assert } from 'chai';
 import { assert } from 'chai';
 
 
-import { IObfuscationResult } from '../../../../src/interfaces/IObfuscationResult';
-
 import { NO_ADDITIONAL_NODES_PRESET } from '../../../../src/options/presets/NoCustomNodes';
 import { NO_ADDITIONAL_NODES_PRESET } from '../../../../src/options/presets/NoCustomNodes';
 
 
 import { readFileAsString } from '../../../helpers/readFileAsString';
 import { readFileAsString } from '../../../helpers/readFileAsString';
@@ -17,16 +15,14 @@ describe('StringArrayNode', () => {
         before(() => {
         before(() => {
             const code: string = readFileAsString(__dirname + '/fixtures/simple-input.js');
             const code: string = readFileAsString(__dirname + '/fixtures/simple-input.js');
 
 
-            let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+            obfuscatedCode = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET,
                     ...NO_ADDITIONAL_NODES_PRESET,
                     stringArray: true,
                     stringArray: true,
                     stringArrayThreshold: 1
                     stringArrayThreshold: 1
                 }
                 }
-            );
-
-            obfuscatedCode = obfuscationResult.getObfuscatedCode();
+            ).getObfuscatedCode();
         });
         });
 
 
         it('should correctly append custom node into the obfuscated code', () => {
         it('should correctly append custom node into the obfuscated code', () => {
@@ -40,15 +36,13 @@ describe('StringArrayNode', () => {
         before(() => {
         before(() => {
             const code: string = readFileAsString(__dirname + '/fixtures/simple-input.js');
             const code: string = readFileAsString(__dirname + '/fixtures/simple-input.js');
 
 
-            let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+            obfuscatedCode = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET,
                     ...NO_ADDITIONAL_NODES_PRESET,
                     stringArray: false
                     stringArray: false
                 }
                 }
-            );
-
-            obfuscatedCode = obfuscationResult.getObfuscatedCode();
+            ).getObfuscatedCode();
         });
         });
 
 
         it('shouldn\'t append custom node into the obfuscated code', () => {
         it('shouldn\'t append custom node into the obfuscated code', () => {

+ 4 - 10
test/functional-tests/custom-nodes/string-array-nodes/StringArrayRotateFunctionNode.spec.ts

@@ -1,7 +1,5 @@
 import { assert } from 'chai';
 import { assert } from 'chai';
 
 
-import { IObfuscationResult } from '../../../../src/interfaces/IObfuscationResult';
-
 import { NO_ADDITIONAL_NODES_PRESET } from '../../../../src/options/presets/NoCustomNodes';
 import { NO_ADDITIONAL_NODES_PRESET } from '../../../../src/options/presets/NoCustomNodes';
 
 
 import { readFileAsString } from '../../../helpers/readFileAsString';
 import { readFileAsString } from '../../../helpers/readFileAsString';
@@ -17,7 +15,7 @@ describe('StringArrayRotateFunctionNode', () => {
         before(() => {
         before(() => {
             const code: string = readFileAsString(__dirname + '/fixtures/simple-input.js');
             const code: string = readFileAsString(__dirname + '/fixtures/simple-input.js');
 
 
-            let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+            obfuscatedCode = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET,
                     ...NO_ADDITIONAL_NODES_PRESET,
@@ -25,9 +23,7 @@ describe('StringArrayRotateFunctionNode', () => {
                     stringArray: true,
                     stringArray: true,
                     stringArrayThreshold: 1
                     stringArrayThreshold: 1
                 }
                 }
-            );
-
-            obfuscatedCode = obfuscationResult.getObfuscatedCode();
+            ).getObfuscatedCode();
         });
         });
 
 
         it('should correctly append custom node into the obfuscated code', () => {
         it('should correctly append custom node into the obfuscated code', () => {
@@ -41,7 +37,7 @@ describe('StringArrayRotateFunctionNode', () => {
         before(() => {
         before(() => {
             const code: string = readFileAsString(__dirname + '/fixtures/simple-input.js');
             const code: string = readFileAsString(__dirname + '/fixtures/simple-input.js');
 
 
-            let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+            obfuscatedCode = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET,
                     ...NO_ADDITIONAL_NODES_PRESET,
@@ -49,9 +45,7 @@ describe('StringArrayRotateFunctionNode', () => {
                     stringArray: true,
                     stringArray: true,
                     stringArrayThreshold: 1
                     stringArrayThreshold: 1
                 }
                 }
-            );
-
-            obfuscatedCode = obfuscationResult.getObfuscatedCode();
+            ).getObfuscatedCode();
         });
         });
 
 
         it('shouldn\'t append custom node into the obfuscated code', () => {
         it('shouldn\'t append custom node into the obfuscated code', () => {

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

@@ -1,6 +1,6 @@
 import { assert } from 'chai';
 import { assert } from 'chai';
 
 
-import { IObfuscationResult } from '../../../src/interfaces/IObfuscationResult';
+import { IObfuscatedCode } from '../../../src/interfaces/source-code/IObfuscatedCode';
 
 
 import { SourceMapMode } from '../../../src/enums/source-map/SourceMapMode';
 import { SourceMapMode } from '../../../src/enums/source-map/SourceMapMode';
 import { StringArrayEncoding } from '../../../src/enums/StringArrayEncoding';
 import { StringArrayEncoding } from '../../../src/enums/StringArrayEncoding';
@@ -23,15 +23,15 @@ describe('JavaScriptObfuscator', () => {
 
 
             beforeEach(() => {
             beforeEach(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/simple-input-1.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/simple-input-1.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+                const obfuscatedCodeObject: IObfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET
                         ...NO_ADDITIONAL_NODES_PRESET
                     }
                     }
                 );
                 );
 
 
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
-                sourceMap = obfuscationResult.getSourceMap();
+                obfuscatedCode = obfuscatedCodeObject.getObfuscatedCode();
+                sourceMap = obfuscatedCodeObject.getSourceMap();
             });
             });
 
 
             it('should return correct obfuscated code', () => {
             it('should return correct obfuscated code', () => {
@@ -48,11 +48,10 @@ describe('JavaScriptObfuscator', () => {
 
 
             beforeEach(() => {
             beforeEach(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/empty-input.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/empty-input.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
-                    code,
-                );
 
 
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
+                    code,
+                ).getObfuscatedCode();
             });
             });
 
 
             it('should return an empty obfuscated code', () => {
             it('should return an empty obfuscated code', () => {
@@ -65,15 +64,14 @@ describe('JavaScriptObfuscator', () => {
 
 
             beforeEach(() => {
             beforeEach(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/comments-only.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/comments-only.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         controlFlowFlattening: true,
                         controlFlowFlattening: true,
                         deadCodeInjection: true
                         deadCodeInjection: true
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('should return an empty obfuscated code', () => {
             it('should return an empty obfuscated code', () => {
@@ -88,7 +86,7 @@ describe('JavaScriptObfuscator', () => {
 
 
                 beforeEach(() => {
                 beforeEach(() => {
                     const code: string = readFileAsString(__dirname + '/fixtures/simple-input-1.js');
                     const code: string = readFileAsString(__dirname + '/fixtures/simple-input-1.js');
-                    const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+                    const obfuscatedCodeObject: IObfuscatedCode = JavaScriptObfuscator.obfuscate(
                         code,
                         code,
                         {
                         {
                             ...NO_ADDITIONAL_NODES_PRESET,
                             ...NO_ADDITIONAL_NODES_PRESET,
@@ -96,8 +94,8 @@ describe('JavaScriptObfuscator', () => {
                         }
                         }
                     );
                     );
 
 
-                    obfuscatedCode = obfuscationResult.getObfuscatedCode();
-                    sourceMap = JSON.parse(obfuscationResult.getSourceMap()).mappings;
+                    obfuscatedCode = obfuscatedCodeObject.getObfuscatedCode();
+                    sourceMap = JSON.parse(obfuscatedCodeObject.getSourceMap()).mappings;
                 });
                 });
 
 
                 it('should return correct obfuscated code', () => {
                 it('should return correct obfuscated code', () => {
@@ -117,7 +115,7 @@ describe('JavaScriptObfuscator', () => {
 
 
                 beforeEach(() => {
                 beforeEach(() => {
                     const code: string = readFileAsString(__dirname + '/fixtures/simple-input-1.js');
                     const code: string = readFileAsString(__dirname + '/fixtures/simple-input-1.js');
-                    const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+                    const obfuscatedCodeObject: IObfuscatedCode = JavaScriptObfuscator.obfuscate(
                         code,
                         code,
                         {
                         {
                             ...NO_ADDITIONAL_NODES_PRESET,
                             ...NO_ADDITIONAL_NODES_PRESET,
@@ -126,8 +124,8 @@ describe('JavaScriptObfuscator', () => {
                         }
                         }
                     );
                     );
 
 
-                    obfuscatedCode = obfuscationResult.getObfuscatedCode();
-                    sourceMap = JSON.parse(obfuscationResult.getSourceMap()).mappings;
+                    obfuscatedCode = obfuscatedCodeObject.getObfuscatedCode();
+                    sourceMap = JSON.parse(obfuscatedCodeObject.getSourceMap()).mappings;
                 });
                 });
 
 
                 it('should return correct obfuscated code', () => {
                 it('should return correct obfuscated code', () => {
@@ -151,16 +149,16 @@ describe('JavaScriptObfuscator', () => {
 
 
                 beforeEach(() => {
                 beforeEach(() => {
                     const code: string = readFileAsString(__dirname + '/fixtures/empty-input.js');
                     const code: string = readFileAsString(__dirname + '/fixtures/empty-input.js');
-                    const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+                    const obfuscatedCodeObject: IObfuscatedCode = JavaScriptObfuscator.obfuscate(
                         code,
                         code,
                         {
                         {
                             sourceMap: true
                             sourceMap: true
                         }
                         }
                     );
                     );
 
 
-                    obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                    obfuscatedCode = obfuscatedCodeObject.getObfuscatedCode();
 
 
-                    const sourceMapObject: any = JSON.parse(obfuscationResult.getSourceMap());
+                    const sourceMapObject: any = JSON.parse(obfuscatedCodeObject.getSourceMap());
 
 
                     sourceMapNames = sourceMapObject.names;
                     sourceMapNames = sourceMapObject.names;
                     sourceMapSources = sourceMapObject.sources;
                     sourceMapSources = sourceMapObject.sources;
@@ -193,14 +191,13 @@ describe('JavaScriptObfuscator', () => {
 
 
                 beforeEach(() => {
                 beforeEach(() => {
                     const code: string = readFileAsString(__dirname + '/fixtures/simple-input-1.js');
                     const code: string = readFileAsString(__dirname + '/fixtures/simple-input-1.js');
-                    const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                    obfuscatedCode = JavaScriptObfuscator.obfuscate(
                         code,
                         code,
                         {
                         {
                             ...NO_ADDITIONAL_NODES_PRESET
                             ...NO_ADDITIONAL_NODES_PRESET
                         }
                         }
-                    );
-
-                    obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                    ).getObfuscatedCode();
                 });
                 });
 
 
                 it('should return correct obfuscated code', () => {
                 it('should return correct obfuscated code', () => {
@@ -215,15 +212,14 @@ describe('JavaScriptObfuscator', () => {
 
 
                 beforeEach(() => {
                 beforeEach(() => {
                     const code: string = readFileAsString(__dirname + '/fixtures/simple-input-1.js');
                     const code: string = readFileAsString(__dirname + '/fixtures/simple-input-1.js');
-                    const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                    obfuscatedCode = JavaScriptObfuscator.obfuscate(
                         code,
                         code,
                         {
                         {
                             ...NO_ADDITIONAL_NODES_PRESET,
                             ...NO_ADDITIONAL_NODES_PRESET,
                             renameGlobals: true
                             renameGlobals: true
                         }
                         }
-                    );
-
-                    obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                    ).getObfuscatedCode();
                 });
                 });
 
 
                 it('should return correct obfuscated code', () => {
                 it('should return correct obfuscated code', () => {
@@ -238,16 +234,15 @@ describe('JavaScriptObfuscator', () => {
 
 
                 beforeEach(() => {
                 beforeEach(() => {
                     const code: string = readFileAsString(__dirname + '/fixtures/simple-input-1.js');
                     const code: string = readFileAsString(__dirname + '/fixtures/simple-input-1.js');
-                    const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                    obfuscatedCode = JavaScriptObfuscator.obfuscate(
                         code,
                         code,
                         {
                         {
                             ...NO_ADDITIONAL_NODES_PRESET,
                             ...NO_ADDITIONAL_NODES_PRESET,
                             renameGlobals: true,
                             renameGlobals: true,
                             identifiersPrefix: 'foo'
                             identifiersPrefix: 'foo'
                         }
                         }
-                    );
-
-                    obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                    ).getObfuscatedCode();
                 });
                 });
 
 
                 it('should return correct obfuscated code', () => {
                 it('should return correct obfuscated code', () => {
@@ -263,7 +258,8 @@ describe('JavaScriptObfuscator', () => {
 
 
                 beforeEach(() => {
                 beforeEach(() => {
                     const code: string = readFileAsString(__dirname + '/fixtures/simple-input-2.js');
                     const code: string = readFileAsString(__dirname + '/fixtures/simple-input-2.js');
-                    const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                    obfuscatedCode = JavaScriptObfuscator.obfuscate(
                         code,
                         code,
                         {
                         {
                             ...NO_ADDITIONAL_NODES_PRESET,
                             ...NO_ADDITIONAL_NODES_PRESET,
@@ -272,9 +268,7 @@ describe('JavaScriptObfuscator', () => {
                             stringArray: true,
                             stringArray: true,
                             stringArrayThreshold: 1
                             stringArrayThreshold: 1
                         }
                         }
-                    );
-
-                    obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                    ).getObfuscatedCode();
                 });
                 });
 
 
                 it('match #1: should return correct obfuscated code', () => {
                 it('match #1: should return correct obfuscated code', () => {
@@ -294,14 +288,13 @@ describe('JavaScriptObfuscator', () => {
 
 
             beforeEach(() => {
             beforeEach(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/block-scope.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/block-scope.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET
                         ...NO_ADDITIONAL_NODES_PRESET
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('should return correct obfuscated code', () => {
             it('should return correct obfuscated code', () => {
@@ -320,16 +313,15 @@ describe('JavaScriptObfuscator', () => {
 
 
                 beforeEach(() => {
                 beforeEach(() => {
                     const code: string = readFileAsString(__dirname + '/fixtures/identifiers-prefix.js');
                     const code: string = readFileAsString(__dirname + '/fixtures/identifiers-prefix.js');
-                    const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                    obfuscatedCode = JavaScriptObfuscator.obfuscate(
                         code,
                         code,
                         {
                         {
                             ...NO_ADDITIONAL_NODES_PRESET,
                             ...NO_ADDITIONAL_NODES_PRESET,
                             renameGlobals: true,
                             renameGlobals: true,
                             identifiersPrefix: 'foo'
                             identifiersPrefix: 'foo'
                         }
                         }
-                    );
-
-                    obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                    ).getObfuscatedCode();
                 });
                 });
 
 
                 it('match #1: should return correct obfuscated code', () => {
                 it('match #1: should return correct obfuscated code', () => {
@@ -358,16 +350,15 @@ describe('JavaScriptObfuscator', () => {
 
 
             beforeEach(() => {
             beforeEach(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/simple-input-2.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/simple-input-2.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
                         stringArray: true,
                         stringArray: true,
                         stringArrayThreshold: 1
                         stringArrayThreshold: 1
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('match #1: should return correct obfuscated code', () => {
             it('match #1: should return correct obfuscated code', () => {
@@ -387,16 +378,15 @@ describe('JavaScriptObfuscator', () => {
 
 
             beforeEach(() => {
             beforeEach(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/simple-input-cyrillic.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/simple-input-cyrillic.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
                         stringArray: true,
                         stringArray: true,
                         stringArrayThreshold: 1
                         stringArrayThreshold: 1
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('match #1: should return correct obfuscated code', () => {
             it('match #1: should return correct obfuscated code', () => {
@@ -426,21 +416,18 @@ describe('JavaScriptObfuscator', () => {
                             seed++;
                             seed++;
                         }
                         }
 
 
-                        const obfuscationResult1: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+                        obfuscatedCode1 = JavaScriptObfuscator.obfuscate(
                             code,
                             code,
                             {
                             {
                                 seed: seed
                                 seed: seed
                             }
                             }
-                        );
-                        const obfuscationResult2: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+                        ).getObfuscatedCode();
+                        obfuscatedCode2 = JavaScriptObfuscator.obfuscate(
                             code,
                             code,
                             {
                             {
                                 seed: seed
                                 seed: seed
                             }
                             }
-                        );
-
-                        obfuscatedCode1 = obfuscationResult1.getObfuscatedCode();
-                        obfuscatedCode2 = obfuscationResult2.getObfuscatedCode();
+                        ).getObfuscatedCode();
 
 
                         if (obfuscatedCode1 === obfuscatedCode2) {
                         if (obfuscatedCode1 === obfuscatedCode2) {
                             equalsCount++;
                             equalsCount++;
@@ -460,21 +447,18 @@ describe('JavaScriptObfuscator', () => {
                     obfuscatedCode2: string;
                     obfuscatedCode2: string;
 
 
                 beforeEach(() => {
                 beforeEach(() => {
-                    const obfuscationResult1: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+                    obfuscatedCode1 = JavaScriptObfuscator.obfuscate(
                         code,
                         code,
                         {
                         {
                             seed: 12345
                             seed: 12345
                         }
                         }
-                    );
-                    const obfuscationResult2: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+                    ).getObfuscatedCode();
+                    obfuscatedCode2 = JavaScriptObfuscator.obfuscate(
                         code,
                         code,
                         {
                         {
                             seed: 12346
                             seed: 12346
                         }
                         }
-                    );
-
-                    obfuscatedCode1 = obfuscationResult1.getObfuscatedCode();
-                    obfuscatedCode2 = obfuscationResult2.getObfuscatedCode();
+                    ).getObfuscatedCode();
                 });
                 });
 
 
                 it('should return different obfuscated code with different `seed` option value', () => {
                 it('should return different obfuscated code with different `seed` option value', () => {
@@ -489,21 +473,18 @@ describe('JavaScriptObfuscator', () => {
                     obfuscatedCode2: string;
                     obfuscatedCode2: string;
 
 
                 beforeEach(() => {
                 beforeEach(() => {
-                    const obfuscationResult1: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+                    obfuscatedCode1 = JavaScriptObfuscator.obfuscate(
                         code,
                         code,
                         {
                         {
                             seed: 0
                             seed: 0
                         }
                         }
-                    );
-                    const obfuscationResult2: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+                    ).getObfuscatedCode();
+                    obfuscatedCode2 = JavaScriptObfuscator.obfuscate(
                         code,
                         code,
                         {
                         {
                             seed: 0
                             seed: 0
                         }
                         }
-                    );
-
-                    obfuscatedCode1 = obfuscationResult1.getObfuscatedCode();
-                    obfuscatedCode2 = obfuscationResult2.getObfuscatedCode();
+                    ).getObfuscatedCode();
                 });
                 });
 
 
                 it('should return different obfuscated code with different `seed` option value', () => {
                 it('should return different obfuscated code with different `seed` option value', () => {
@@ -521,23 +502,20 @@ describe('JavaScriptObfuscator', () => {
                     match2: string;
                     match2: string;
 
 
                 beforeEach(() => {
                 beforeEach(() => {
-                    const obfuscationResult1: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+                    const obfuscatedCode1: string = JavaScriptObfuscator.obfuscate(
                         code1,
                         code1,
                         {
                         {
                             seed: 123,
                             seed: 123,
                             stringArrayThreshold: 1
                             stringArrayThreshold: 1
                         }
                         }
-                    );
-                    const obfuscationResult2: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+                    ).getObfuscatedCode();
+                    const obfuscatedCode2: string = JavaScriptObfuscator.obfuscate(
                         code2,
                         code2,
                         {
                         {
                             seed: 123,
                             seed: 123,
                             stringArrayThreshold: 1
                             stringArrayThreshold: 1
                         }
                         }
-                    );
-
-                    const obfuscatedCode1: string = obfuscationResult1.getObfuscatedCode();
-                    const obfuscatedCode2: string = obfuscationResult2.getObfuscatedCode();
+                    ).getObfuscatedCode();
 
 
                     match1 = getRegExpMatch(obfuscatedCode1, regExp);
                     match1 = getRegExpMatch(obfuscatedCode1, regExp);
                     match2 = getRegExpMatch(obfuscatedCode2, regExp);
                     match2 = getRegExpMatch(obfuscatedCode2, regExp);
@@ -556,14 +534,13 @@ describe('JavaScriptObfuscator', () => {
 
 
             beforeEach(() => {
             beforeEach(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/new-target.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/new-target.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET
                         ...NO_ADDITIONAL_NODES_PRESET
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('should keep new.target MetaProperty', () => {
             it('should keep new.target MetaProperty', () => {
@@ -578,14 +555,13 @@ describe('JavaScriptObfuscator', () => {
 
 
             beforeEach(() => {
             beforeEach(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/mangle.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/mangle.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         identifierNamesGenerator: IdentifierNamesGenerator.MangledIdentifierNamesGenerator
                         identifierNamesGenerator: IdentifierNamesGenerator.MangledIdentifierNamesGenerator
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('should mangle obfuscated code', () => {
             it('should mangle obfuscated code', () => {
@@ -602,9 +578,8 @@ describe('JavaScriptObfuscator', () => {
 
 
                 beforeEach(() => {
                 beforeEach(() => {
                     const code: string = readFileAsString(__dirname + '/fixtures/parse-module-1.js');
                     const code: string = readFileAsString(__dirname + '/fixtures/parse-module-1.js');
-                    const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(code);
 
 
-                    obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                    obfuscatedCode = JavaScriptObfuscator.obfuscate(code).getObfuscatedCode();
                 });
                 });
 
 
                 it('Match #!: should correctly obfuscate a import', () => {
                 it('Match #!: should correctly obfuscate a import', () => {
@@ -623,9 +598,8 @@ describe('JavaScriptObfuscator', () => {
 
 
                 beforeEach(() => {
                 beforeEach(() => {
                     const code: string = readFileAsString(__dirname + '/fixtures/parse-module-2.js');
                     const code: string = readFileAsString(__dirname + '/fixtures/parse-module-2.js');
-                    const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(code);
 
 
-                    obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                    obfuscatedCode = JavaScriptObfuscator.obfuscate(code).getObfuscatedCode();
                 });
                 });
 
 
                 it('should correctly obfuscate a module', () => {
                 it('should correctly obfuscate a module', () => {
@@ -643,7 +617,8 @@ describe('JavaScriptObfuscator', () => {
 
 
             beforeEach(() => {
             beforeEach(() => {
                 const code: string = buildLargeCode(expectedValue);
                 const code: string = buildLargeCode(expectedValue);
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                const obfuscatedCode: string = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         compact: true,
                         compact: true,
@@ -659,9 +634,8 @@ describe('JavaScriptObfuscator', () => {
                         transformObjectKeys: true,
                         transformObjectKeys: true,
                         unicodeEscapeSequence: false
                         unicodeEscapeSequence: false
                     }
                     }
-                );
+                ).getObfuscatedCode();
 
 
-                const obfuscatedCode: string = obfuscationResult.getObfuscatedCode();
                 result = eval(obfuscatedCode);
                 result = eval(obfuscatedCode);
             });
             });
 
 

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

@@ -1,7 +1,5 @@
 import { assert } from 'chai';
 import { assert } from 'chai';
 
 
-import { IObfuscationResult } from '../../../../../src/interfaces/IObfuscationResult';
-
 import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes';
 import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes';
 
 
 import { getRegExpMatch } from '../../../../helpers/getRegExpMatch';
 import { getRegExpMatch } from '../../../../helpers/getRegExpMatch';
@@ -26,16 +24,15 @@ describe('BlockStatementControlFlowTransformer', function () {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/input-1.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/input-1.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
                         controlFlowFlattening: true,
                         controlFlowFlattening: true,
                         controlFlowFlatteningThreshold: 1
                         controlFlowFlatteningThreshold: 1
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             describe('`console.log` statements', ()=> {
             describe('`console.log` statements', ()=> {
@@ -114,7 +111,8 @@ describe('BlockStatementControlFlowTransformer', function () {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/input-2.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/input-2.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
@@ -122,9 +120,7 @@ describe('BlockStatementControlFlowTransformer', function () {
                         controlFlowFlatteningThreshold: 1,
                         controlFlowFlatteningThreshold: 1,
                         unicodeEscapeSequence: false
                         unicodeEscapeSequence: false
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             describe('`console.log` statements', ()=> {
             describe('`console.log` statements', ()=> {
@@ -205,16 +201,15 @@ describe('BlockStatementControlFlowTransformer', function () {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/one-statement.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/one-statement.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
                         controlFlowFlattening: true,
                         controlFlowFlattening: true,
                         controlFlowFlatteningThreshold: 1
                         controlFlowFlatteningThreshold: 1
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('shouldn\'t transform block statement', () => {
             it('shouldn\'t transform block statement', () => {
@@ -229,16 +224,15 @@ describe('BlockStatementControlFlowTransformer', function () {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/const-declaration.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/const-declaration.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
                         controlFlowFlattening: true,
                         controlFlowFlattening: true,
                         controlFlowFlatteningThreshold: 1
                         controlFlowFlatteningThreshold: 1
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('shouldn\'t transform block statement', () => {
             it('shouldn\'t transform block statement', () => {
@@ -253,16 +247,15 @@ describe('BlockStatementControlFlowTransformer', function () {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/let-declaration.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/let-declaration.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
                         controlFlowFlattening: true,
                         controlFlowFlattening: true,
                         controlFlowFlatteningThreshold: 1
                         controlFlowFlatteningThreshold: 1
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('shouldn\'t transform block statement', () => {
             it('shouldn\'t transform block statement', () => {
@@ -277,16 +270,15 @@ describe('BlockStatementControlFlowTransformer', function () {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/break-statement-1.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/break-statement-1.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
                         controlFlowFlattening: true,
                         controlFlowFlattening: true,
                         controlFlowFlatteningThreshold: 1
                         controlFlowFlatteningThreshold: 1
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('shouldn\'t transform block statement', () => {
             it('shouldn\'t transform block statement', () => {
@@ -301,16 +293,15 @@ describe('BlockStatementControlFlowTransformer', function () {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/break-statement-2.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/break-statement-2.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
                         controlFlowFlattening: true,
                         controlFlowFlattening: true,
                         controlFlowFlatteningThreshold: 1
                         controlFlowFlatteningThreshold: 1
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('shouldn\'t transform block statement', () => {
             it('shouldn\'t transform block statement', () => {
@@ -328,16 +319,15 @@ describe('BlockStatementControlFlowTransformer', function () {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/break-statement-inside-while-statement.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/break-statement-inside-while-statement.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
                         controlFlowFlattening: true,
                         controlFlowFlattening: true,
                         controlFlowFlatteningThreshold: 1
                         controlFlowFlatteningThreshold: 1
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
                 switchCaseLength = obfuscatedCode.match(switchCaseLengthRegExp)!.length;
                 switchCaseLength = obfuscatedCode.match(switchCaseLengthRegExp)!.length;
             });
             });
 
 
@@ -357,16 +347,15 @@ describe('BlockStatementControlFlowTransformer', function () {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/continue-statement-1.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/continue-statement-1.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
                         controlFlowFlattening: true,
                         controlFlowFlattening: true,
                         controlFlowFlatteningThreshold: 1
                         controlFlowFlatteningThreshold: 1
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('shouldn\'t transform block statement', () => {
             it('shouldn\'t transform block statement', () => {
@@ -381,16 +370,15 @@ describe('BlockStatementControlFlowTransformer', function () {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/continue-statement-2.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/continue-statement-2.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
                         controlFlowFlattening: true,
                         controlFlowFlattening: true,
                         controlFlowFlatteningThreshold: 1
                         controlFlowFlatteningThreshold: 1
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('shouldn\'t transform block statement', () => {
             it('shouldn\'t transform block statement', () => {
@@ -408,16 +396,15 @@ describe('BlockStatementControlFlowTransformer', function () {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/continue-statement-inside-while-statement.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/continue-statement-inside-while-statement.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
                         controlFlowFlattening: true,
                         controlFlowFlattening: true,
                         controlFlowFlatteningThreshold: 1
                         controlFlowFlatteningThreshold: 1
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
                 switchCaseLength = obfuscatedCode.match(switchCaseLengthRegExp)!.length;
                 switchCaseLength = obfuscatedCode.match(switchCaseLengthRegExp)!.length;
             });
             });
 
 
@@ -437,16 +424,15 @@ describe('BlockStatementControlFlowTransformer', function () {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/function-declaration.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/function-declaration.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
                         controlFlowFlattening: true,
                         controlFlowFlattening: true,
                         controlFlowFlatteningThreshold: 1
                         controlFlowFlatteningThreshold: 1
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('shouldn\'t transform block statement', () => {
             it('shouldn\'t transform block statement', () => {
@@ -461,16 +447,15 @@ describe('BlockStatementControlFlowTransformer', function () {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/class-declaration.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/class-declaration.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
                         controlFlowFlattening: true,
                         controlFlowFlattening: true,
                         controlFlowFlatteningThreshold: 1
                         controlFlowFlatteningThreshold: 1
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('shouldn\'t transform block statement', () => {
             it('shouldn\'t transform block statement', () => {
@@ -492,21 +477,20 @@ describe('BlockStatementControlFlowTransformer', function () {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/input-1.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/input-1.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                const obfuscatedCode: string = JavaScriptObfuscator.obfuscate(
                     code.repeat(samples),
                     code.repeat(samples),
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
                         controlFlowFlattening: true,
                         controlFlowFlattening: true,
                         controlFlowFlatteningThreshold: controlFlowFlatteningThreshold,
                         controlFlowFlatteningThreshold: controlFlowFlatteningThreshold,
                     }
                     }
-                );
+                ).getObfuscatedCode();
 
 
-                const transformedStatementMatchesLength: number = obfuscationResult
-                    .getObfuscatedCode()
+                const transformedStatementMatchesLength: number = obfuscatedCode
                     .match(regExp1)!
                     .match(regExp1)!
                     .length;
                     .length;
-                const untouchedStatementMatchesLength: number = obfuscationResult
-                    .getObfuscatedCode()
+                const untouchedStatementMatchesLength: number = obfuscatedCode
                     .match(regExp2)!
                     .match(regExp2)!
                     .length;
                     .length;
 
 
@@ -534,16 +518,15 @@ describe('BlockStatementControlFlowTransformer', function () {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/no-unreachable-code-warning.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/no-unreachable-code-warning.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
                         controlFlowFlattening: true,
                         controlFlowFlattening: true,
                         controlFlowFlatteningThreshold: 1
                         controlFlowFlatteningThreshold: 1
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
                 switchCaseLength = obfuscatedCode.match(switchCaseLengthRegExp)!.length;
                 switchCaseLength = obfuscatedCode.match(switchCaseLengthRegExp)!.length;
             });
             });
 
 

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

@@ -1,7 +1,5 @@
 import { assert } from 'chai';
 import { assert } from 'chai';
 
 
-import { IObfuscationResult } from '../../../../../../src/interfaces/IObfuscationResult';
-
 import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../../src/options/presets/NoCustomNodes';
 import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../../src/options/presets/NoCustomNodes';
 
 
 import { readFileAsString } from '../../../../../helpers/readFileAsString';
 import { readFileAsString } from '../../../../../helpers/readFileAsString';
@@ -19,16 +17,15 @@ describe('BinaryExpressionControlFlowReplacer', function () {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/input-1.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/input-1.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
                         controlFlowFlattening: true,
                         controlFlowFlattening: true,
                         controlFlowFlatteningThreshold: 1
                         controlFlowFlatteningThreshold: 1
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('should replace binary expression node with call to control flow storage node', () => {
             it('should replace binary expression node with call to control flow storage node', () => {
@@ -52,8 +49,7 @@ describe('BinaryExpressionControlFlowReplacer', function () {
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/input-2.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/input-2.js');
 
 
-                let obfuscationResult: IObfuscationResult,
-                    obfuscatedCode: string,
+                let obfuscatedCode: string,
                     firstMatchArray: RegExpMatchArray | null,
                     firstMatchArray: RegExpMatchArray | null,
                     secondMatchArray: RegExpMatchArray | null,
                     secondMatchArray: RegExpMatchArray | null,
                     firstMatch: string | undefined,
                     firstMatch: string | undefined,
@@ -61,16 +57,14 @@ describe('BinaryExpressionControlFlowReplacer', function () {
                     equalsValue: number = 0;
                     equalsValue: number = 0;
 
 
                 for (let i = 0; i < samplesCount; i++) {
                 for (let i = 0; i < samplesCount; i++) {
-                    obfuscationResult = JavaScriptObfuscator.obfuscate(
+                    obfuscatedCode = JavaScriptObfuscator.obfuscate(
                         code,
                         code,
                         {
                         {
                             ...NO_ADDITIONAL_NODES_PRESET,
                             ...NO_ADDITIONAL_NODES_PRESET,
                             controlFlowFlattening: true,
                             controlFlowFlattening: true,
                             controlFlowFlatteningThreshold: 1
                             controlFlowFlatteningThreshold: 1
                         }
                         }
-                    );
-
-                    obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                    ).getObfuscatedCode();
 
 
                     firstMatchArray = obfuscatedCode.match(controlFlowStorageCallRegExp1);
                     firstMatchArray = obfuscatedCode.match(controlFlowStorageCallRegExp1);
                     secondMatchArray = obfuscatedCode.match(controlFlowStorageCallRegExp2);
                     secondMatchArray = obfuscatedCode.match(controlFlowStorageCallRegExp2);

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

@@ -1,7 +1,5 @@
 import { assert } from 'chai';
 import { assert } from 'chai';
 
 
-import { IObfuscationResult } from '../../../../../../src/interfaces/IObfuscationResult';
-
 import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../../src/options/presets/NoCustomNodes';
 import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../../src/options/presets/NoCustomNodes';
 
 
 import { readFileAsString } from '../../../../../helpers/readFileAsString';
 import { readFileAsString } from '../../../../../helpers/readFileAsString';
@@ -19,16 +17,15 @@ describe('CallExpressionControlFlowReplacer', function () {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/input-1.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/input-1.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
                         controlFlowFlattening: true,
                         controlFlowFlattening: true,
                         controlFlowFlatteningThreshold: 1
                         controlFlowFlatteningThreshold: 1
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('should replace call expression node with call to control flow storage node', () => {
             it('should replace call expression node with call to control flow storage node', () => {
@@ -52,8 +49,7 @@ describe('CallExpressionControlFlowReplacer', function () {
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/input-2.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/input-2.js');
 
 
-                let obfuscationResult: IObfuscationResult,
-                    obfuscatedCode: string,
+                let obfuscatedCode: string,
                     firstMatchArray: RegExpMatchArray | null,
                     firstMatchArray: RegExpMatchArray | null,
                     secondMatchArray: RegExpMatchArray | null,
                     secondMatchArray: RegExpMatchArray | null,
                     firstMatch: string | undefined,
                     firstMatch: string | undefined,
@@ -61,16 +57,14 @@ describe('CallExpressionControlFlowReplacer', function () {
                     equalsValue: number = 0;
                     equalsValue: number = 0;
 
 
                 for (let i = 0; i < samplesCount; i++) {
                 for (let i = 0; i < samplesCount; i++) {
-                    obfuscationResult = JavaScriptObfuscator.obfuscate(
+                    obfuscatedCode = JavaScriptObfuscator.obfuscate(
                         code,
                         code,
                         {
                         {
                             ...NO_ADDITIONAL_NODES_PRESET,
                             ...NO_ADDITIONAL_NODES_PRESET,
                             controlFlowFlattening: true,
                             controlFlowFlattening: true,
                             controlFlowFlatteningThreshold: 1
                             controlFlowFlatteningThreshold: 1
                         }
                         }
-                    );
-
-                    obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                    ).getObfuscatedCode();
 
 
                     firstMatchArray = obfuscatedCode.match(controlFlowStorageCallRegExp1);
                     firstMatchArray = obfuscatedCode.match(controlFlowStorageCallRegExp1);
                     secondMatchArray = obfuscatedCode.match(controlFlowStorageCallRegExp2);
                     secondMatchArray = obfuscatedCode.match(controlFlowStorageCallRegExp2);
@@ -108,16 +102,15 @@ describe('CallExpressionControlFlowReplacer', function () {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/input-3.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/input-3.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
                         controlFlowFlattening: true,
                         controlFlowFlattening: true,
                         controlFlowFlatteningThreshold: 1
                         controlFlowFlatteningThreshold: 1
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('shouldn\'t replace call expression node with call to control flow storage node', () => {
             it('shouldn\'t replace call expression node with call to control flow storage node', () => {

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

@@ -1,7 +1,5 @@
 import { assert } from 'chai';
 import { assert } from 'chai';
 
 
-import { IObfuscationResult } from '../../../../../../src/interfaces/IObfuscationResult';
-
 import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../../src/options/presets/NoCustomNodes';
 import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../../src/options/presets/NoCustomNodes';
 
 
 import { readFileAsString } from '../../../../../helpers/readFileAsString';
 import { readFileAsString } from '../../../../../helpers/readFileAsString';
@@ -19,16 +17,15 @@ describe('LogicalExpressionControlFlowReplacer', function () {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/input-1.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/input-1.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
                         controlFlowFlattening: true,
                         controlFlowFlattening: true,
                         controlFlowFlatteningThreshold: 1
                         controlFlowFlatteningThreshold: 1
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('should replace logical expression node with call to control flow storage node', () => {
             it('should replace logical expression node with call to control flow storage node', () => {
@@ -52,8 +49,7 @@ describe('LogicalExpressionControlFlowReplacer', function () {
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/input-2.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/input-2.js');
 
 
-                let obfuscationResult: IObfuscationResult,
-                    obfuscatedCode: string,
+                let obfuscatedCode: string,
                     firstMatchArray: RegExpMatchArray | null,
                     firstMatchArray: RegExpMatchArray | null,
                     secondMatchArray: RegExpMatchArray | null,
                     secondMatchArray: RegExpMatchArray | null,
                     firstMatch: string | undefined,
                     firstMatch: string | undefined,
@@ -61,16 +57,14 @@ describe('LogicalExpressionControlFlowReplacer', function () {
                     equalsValue: number = 0;
                     equalsValue: number = 0;
 
 
                 for (let i = 0; i < samplesCount; i++) {
                 for (let i = 0; i < samplesCount; i++) {
-                    obfuscationResult = JavaScriptObfuscator.obfuscate(
+                    obfuscatedCode = JavaScriptObfuscator.obfuscate(
                         code,
                         code,
                         {
                         {
                             ...NO_ADDITIONAL_NODES_PRESET,
                             ...NO_ADDITIONAL_NODES_PRESET,
                             controlFlowFlattening: true,
                             controlFlowFlattening: true,
                             controlFlowFlatteningThreshold: 1
                             controlFlowFlatteningThreshold: 1
                         }
                         }
-                    );
-
-                    obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                    ).getObfuscatedCode();
 
 
                     firstMatchArray = obfuscatedCode.match(controlFlowStorageCallRegExp1);
                     firstMatchArray = obfuscatedCode.match(controlFlowStorageCallRegExp1);
                     secondMatchArray = obfuscatedCode.match(controlFlowStorageCallRegExp2);
                     secondMatchArray = obfuscatedCode.match(controlFlowStorageCallRegExp2);
@@ -108,16 +102,15 @@ describe('LogicalExpressionControlFlowReplacer', function () {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/input-3.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/input-3.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
                         controlFlowFlattening: true,
                         controlFlowFlattening: true,
                         controlFlowFlatteningThreshold: 1
                         controlFlowFlatteningThreshold: 1
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('should replace logical unary expression with call to control flow storage node', () => {
             it('should replace logical unary expression with call to control flow storage node', () => {
@@ -132,16 +125,15 @@ describe('LogicalExpressionControlFlowReplacer', function () {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/prohibited-nodes.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/prohibited-nodes.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
                         controlFlowFlattening: true,
                         controlFlowFlattening: true,
                         controlFlowFlatteningThreshold: .1
                         controlFlowFlatteningThreshold: .1
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('shouldn\'t replace prohibited expression nodes', () => {
             it('shouldn\'t replace prohibited expression nodes', () => {

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

@@ -1,7 +1,5 @@
 import { assert } from 'chai';
 import { assert } from 'chai';
 
 
-import { IObfuscationResult } from '../../../../../../src/interfaces/IObfuscationResult';
-
 import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../../src/options/presets/NoCustomNodes';
 import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../../src/options/presets/NoCustomNodes';
 
 
 import { readFileAsString } from '../../../../../helpers/readFileAsString';
 import { readFileAsString } from '../../../../../helpers/readFileAsString';
@@ -17,16 +15,15 @@ describe('StringLiteralControlFlowReplacer', () => {
 
 
         before(() => {
         before(() => {
             const code: string = readFileAsString(__dirname + '/fixtures/input-1.js');
             const code: string = readFileAsString(__dirname + '/fixtures/input-1.js');
-            const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+            obfuscatedCode = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET,
                     ...NO_ADDITIONAL_NODES_PRESET,
                     controlFlowFlattening: true,
                     controlFlowFlattening: true,
                     controlFlowFlatteningThreshold: 1
                     controlFlowFlatteningThreshold: 1
                 }
                 }
-            );
-
-            obfuscatedCode = obfuscationResult.getObfuscatedCode();
+            ).getObfuscatedCode();
         });
         });
 
 
         it('should add string literal node as property of control flow storage node', () => {
         it('should add string literal node as property of control flow storage node', () => {

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

@@ -1,7 +1,5 @@
 import { assert } from 'chai';
 import { assert } from 'chai';
 
 
-import { IObfuscationResult } from '../../../../../src/interfaces/IObfuscationResult';
-
 import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes';
 import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes';
 
 
 import { readFileAsString } from '../../../../helpers/readFileAsString';
 import { readFileAsString } from '../../../../helpers/readFileAsString';
@@ -35,16 +33,15 @@ describe('FunctionControlFlowTransformer', function () {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/input-1.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/input-1.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
                         controlFlowFlattening: true,
                         controlFlowFlattening: true,
                         controlFlowFlatteningThreshold: 1
                         controlFlowFlatteningThreshold: 1
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('should add `control flow storage` node to the obfuscated code', () => {
             it('should add `control flow storage` node to the obfuscated code', () => {
@@ -72,20 +69,18 @@ describe('FunctionControlFlowTransformer', function () {
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/input-2.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/input-2.js');
 
 
-                let obfuscationResult: IObfuscationResult,
-                    obfuscatedCode: string,
+                let obfuscatedCode: string,
                     totalValue: number = 0;
                     totalValue: number = 0;
 
 
                 for (let i = 0; i < samplesCount; i++) {
                 for (let i = 0; i < samplesCount; i++) {
-                    obfuscationResult = JavaScriptObfuscator.obfuscate(
+                    obfuscatedCode = JavaScriptObfuscator.obfuscate(
                         code,
                         code,
                         {
                         {
                             ...NO_ADDITIONAL_NODES_PRESET,
                             ...NO_ADDITIONAL_NODES_PRESET,
                             controlFlowFlattening: true,
                             controlFlowFlattening: true,
                             controlFlowFlatteningThreshold: 1
                             controlFlowFlatteningThreshold: 1
                         }
                         }
-                    );
-                    obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                    ).getObfuscatedCode();
 
 
                     if (regExp1.test(obfuscatedCode)) {
                     if (regExp1.test(obfuscatedCode)) {
                         totalValue += obfuscatedCode.match(regExp1)!.length;
                         totalValue += obfuscatedCode.match(regExp1)!.length;
@@ -120,16 +115,15 @@ describe('FunctionControlFlowTransformer', function () {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/multiple-items.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/multiple-items.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
                         controlFlowFlattening: true,
                         controlFlowFlattening: true,
                         controlFlowFlatteningThreshold: 1
                         controlFlowFlatteningThreshold: 1
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('should add `control flow storage` node with multiple items to the obfuscated code', () => {
             it('should add `control flow storage` node with multiple items to the obfuscated code', () => {
@@ -144,16 +138,15 @@ describe('FunctionControlFlowTransformer', function () {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/root-block-scope-1.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/root-block-scope-1.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
                         controlFlowFlattening: true,
                         controlFlowFlattening: true,
                         controlFlowFlatteningThreshold: 1
                         controlFlowFlatteningThreshold: 1
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('should\'t add control flow storage node', () => {
             it('should\'t add control flow storage node', () => {
@@ -179,15 +172,15 @@ describe('FunctionControlFlowTransformer', function () {
 
 
             before(() => {
             before(() => {
                 for (let i = 0; i < samplesCount; i++) {
                 for (let i = 0; i < samplesCount; i++) {
-                    const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                    const obfuscatedCode: string = JavaScriptObfuscator.obfuscate(
                         code,
                         code,
                         {
                         {
                             ...NO_ADDITIONAL_NODES_PRESET,
                             ...NO_ADDITIONAL_NODES_PRESET,
                             controlFlowFlattening: true,
                             controlFlowFlattening: true,
                             controlFlowFlatteningThreshold: 1
                             controlFlowFlatteningThreshold: 1
                         }
                         }
-                    );
-                    const obfuscatedCode: string = obfuscationResult.getObfuscatedCode();
+                    ).getObfuscatedCode();
 
 
                     if (regExp.test(obfuscatedCode)) {
                     if (regExp.test(obfuscatedCode)) {
                         totalValue++;
                         totalValue++;
@@ -208,16 +201,15 @@ describe('FunctionControlFlowTransformer', function () {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/zero-threshold.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/zero-threshold.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
                         controlFlowFlattening: true,
                         controlFlowFlattening: true,
                         controlFlowFlatteningThreshold: 0
                         controlFlowFlatteningThreshold: 0
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('shouldn\'t add call to control flow storage node to the obfuscated code', () => {
             it('shouldn\'t add call to control flow storage node to the obfuscated code', () => {
@@ -237,16 +229,15 @@ describe('FunctionControlFlowTransformer', function () {
 
 
                 before(() => {
                 before(() => {
                     const code: string = readFileAsString(__dirname + '/fixtures/arrow-function-expression-with-body.js');
                     const code: string = readFileAsString(__dirname + '/fixtures/arrow-function-expression-with-body.js');
-                    const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                    obfuscatedCode = JavaScriptObfuscator.obfuscate(
                         code,
                         code,
                         {
                         {
                             ...NO_ADDITIONAL_NODES_PRESET,
                             ...NO_ADDITIONAL_NODES_PRESET,
                             controlFlowFlattening: true,
                             controlFlowFlattening: true,
                             controlFlowFlatteningThreshold: 1
                             controlFlowFlatteningThreshold: 1
                         }
                         }
-                    );
-
-                    obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                    ).getObfuscatedCode();
                 });
                 });
 
 
                 it('should add `control flow storage` node to the obfuscated code', () => {
                 it('should add `control flow storage` node to the obfuscated code', () => {
@@ -261,16 +252,15 @@ describe('FunctionControlFlowTransformer', function () {
 
 
                 before(() => {
                 before(() => {
                     const code: string = readFileAsString(__dirname + '/fixtures/arrow-function-expression-without-body.js');
                     const code: string = readFileAsString(__dirname + '/fixtures/arrow-function-expression-without-body.js');
-                    const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                    obfuscatedCode = JavaScriptObfuscator.obfuscate(
                         code,
                         code,
                         {
                         {
                             ...NO_ADDITIONAL_NODES_PRESET,
                             ...NO_ADDITIONAL_NODES_PRESET,
                             controlFlowFlattening: true,
                             controlFlowFlattening: true,
                             controlFlowFlatteningThreshold: 1
                             controlFlowFlatteningThreshold: 1
                         }
                         }
-                    );
-
-                    obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                    ).getObfuscatedCode();
                 });
                 });
 
 
                 it('shouldn\'t add `control flow storage` node to the obfuscated code', () => {
                 it('shouldn\'t add `control flow storage` node to the obfuscated code', () => {

+ 12 - 18
test/functional-tests/node-transformers/converting-transformers/member-expression-transformer/MemberExpressionTransformer.spec.ts

@@ -1,7 +1,5 @@
 import { assert } from 'chai';
 import { assert } from 'chai';
 
 
-import { IObfuscationResult } from '../../../../../src/interfaces/IObfuscationResult';
-
 import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes';
 import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes';
 
 
 import { readFileAsString } from '../../../../helpers/readFileAsString';
 import { readFileAsString } from '../../../../helpers/readFileAsString';
@@ -17,14 +15,13 @@ describe('MemberExpressionTransformer', () => {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/dot-notation-call.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/dot-notation-call.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET
                         ...NO_ADDITIONAL_NODES_PRESET
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('should replace member expression dot notation call with literal value', () => {
             it('should replace member expression dot notation call with literal value', () => {
@@ -40,16 +37,15 @@ describe('MemberExpressionTransformer', () => {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/dot-notation-call.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/dot-notation-call.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
                         stringArray: true,
                         stringArray: true,
                         stringArrayThreshold: 1
                         stringArrayThreshold: 1
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('should add member expression identifier to string array', () => {
             it('should add member expression identifier to string array', () => {
@@ -71,16 +67,15 @@ describe('MemberExpressionTransformer', () => {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/square-brackets-call.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/square-brackets-call.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
                         stringArray: true,
                         stringArray: true,
                         stringArrayThreshold: 1
                         stringArrayThreshold: 1
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('should add member expression square brackets literal to string array', () => {
             it('should add member expression square brackets literal to string array', () => {
@@ -99,14 +94,13 @@ describe('MemberExpressionTransformer', () => {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/square-brackets-with-identifier-call.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/square-brackets-with-identifier-call.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET
                         ...NO_ADDITIONAL_NODES_PRESET
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('should ignore square brackets call with identifier value', () => {
             it('should ignore square brackets call with identifier value', () => {

+ 12 - 18
test/functional-tests/node-transformers/converting-transformers/method-definition-transformer/MethodDefinitionTransformer.spec.ts

@@ -1,7 +1,5 @@
 import { assert } from 'chai';
 import { assert } from 'chai';
 
 
-import { IObfuscationResult } from '../../../../../src/interfaces/IObfuscationResult';
-
 import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes';
 import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes';
 
 
 import { readFileAsString } from '../../../../helpers/readFileAsString';
 import { readFileAsString } from '../../../../helpers/readFileAsString';
@@ -16,14 +14,13 @@ describe('MethodDefinitionTransformer', () => {
 
 
         before(() => {
         before(() => {
             const code: string = readFileAsString(__dirname + '/fixtures/sample-input.js');
             const code: string = readFileAsString(__dirname + '/fixtures/sample-input.js');
-            const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+            obfuscatedCode = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET
                     ...NO_ADDITIONAL_NODES_PRESET
                 }
                 }
-            );
-
-            obfuscatedCode = obfuscationResult.getObfuscatedCode();
+            ).getObfuscatedCode();
         });
         });
 
 
         it('should replace method definition node `key` property with square brackets literal', () => {
         it('should replace method definition node `key` property with square brackets literal', () => {
@@ -39,16 +36,15 @@ describe('MethodDefinitionTransformer', () => {
 
 
         before(() => {
         before(() => {
             const code: string = readFileAsString(__dirname + '/fixtures/sample-input.js');
             const code: string = readFileAsString(__dirname + '/fixtures/sample-input.js');
-            const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+            obfuscatedCode = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET,
                     ...NO_ADDITIONAL_NODES_PRESET,
                     stringArray: true,
                     stringArray: true,
                     stringArrayThreshold: 1
                     stringArrayThreshold: 1
                 }
                 }
-            );
-
-            obfuscatedCode = obfuscationResult.getObfuscatedCode();
+            ).getObfuscatedCode();
         });
         });
 
 
         it('should add method definition node `key` property to string array', () => {
         it('should add method definition node `key` property to string array', () => {
@@ -67,14 +63,13 @@ describe('MethodDefinitionTransformer', () => {
 
 
         before(() => {
         before(() => {
             const code: string = readFileAsString(__dirname + '/fixtures/sample-input.js');
             const code: string = readFileAsString(__dirname + '/fixtures/sample-input.js');
-            const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+            obfuscatedCode = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET
                     ...NO_ADDITIONAL_NODES_PRESET
                 }
                 }
-            );
-
-            obfuscatedCode = obfuscationResult.getObfuscatedCode();
+            ).getObfuscatedCode();
         });
         });
 
 
         it('shouldn\'t transform method definition node with `constructor` key', () => {
         it('shouldn\'t transform method definition node with `constructor` key', () => {
@@ -90,14 +85,13 @@ describe('MethodDefinitionTransformer', () => {
 
 
         before(() => {
         before(() => {
             const code: string = readFileAsString(__dirname + '/fixtures/async-get-method.js');
             const code: string = readFileAsString(__dirname + '/fixtures/async-get-method.js');
-            const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+            obfuscatedCode = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET,
                     ...NO_ADDITIONAL_NODES_PRESET,
                 }
                 }
-            );
-
-            obfuscatedCode = obfuscationResult.getObfuscatedCode();
+            ).getObfuscatedCode();
         });
         });
 
 
         it('Match #1: should rename class declaration name', () => {
         it('Match #1: should rename class declaration name', () => {

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

@@ -1,7 +1,5 @@
 import { assert } from 'chai';
 import { assert } from 'chai';
 
 
-import { IObfuscationResult } from '../../../../../src/interfaces/IObfuscationResult';
-
 import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes';
 import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes';
 
 
 import { readFileAsString } from '../../../../helpers/readFileAsString';
 import { readFileAsString } from '../../../../helpers/readFileAsString';
@@ -24,15 +22,14 @@ describe('ObjectExpressionKeysTransformer', () => {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/simple.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/simple.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
                         transformObjectKeys: true
                         transformObjectKeys: true
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('should correctly transform object keys', () => {
             it('should correctly transform object keys', () => {
@@ -54,15 +51,14 @@ describe('ObjectExpressionKeysTransformer', () => {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/nested-objects-1.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/nested-objects-1.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
                         transformObjectKeys: true
                         transformObjectKeys: true
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('should correctly transform object keys', () => {
             it('should correctly transform object keys', () => {
@@ -87,15 +83,14 @@ describe('ObjectExpressionKeysTransformer', () => {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/nested-objects-2.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/nested-objects-2.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
                         transformObjectKeys: true
                         transformObjectKeys: true
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('should correctly transform object keys', () => {
             it('should correctly transform object keys', () => {
@@ -117,7 +112,8 @@ describe('ObjectExpressionKeysTransformer', () => {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/integration-with-control-flow-flattening.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/integration-with-control-flow-flattening.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
@@ -125,9 +121,7 @@ describe('ObjectExpressionKeysTransformer', () => {
                         controlFlowFlatteningThreshold: 1,
                         controlFlowFlatteningThreshold: 1,
                         transformObjectKeys: true
                         transformObjectKeys: true
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('should correctly transform object keys', () => {
             it('should correctly transform object keys', () => {
@@ -148,15 +142,14 @@ describe('ObjectExpressionKeysTransformer', () => {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/variable-declaration-without-initialization.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/variable-declaration-without-initialization.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
                         transformObjectKeys: true
                         transformObjectKeys: true
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('shouldn\'t transform object keys', () => {
             it('shouldn\'t transform object keys', () => {
@@ -178,15 +171,14 @@ describe('ObjectExpressionKeysTransformer', () => {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/member-expression-host-1.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/member-expression-host-1.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
                         transformObjectKeys: true
                         transformObjectKeys: true
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('should correctly transform object keys', () => {
             it('should correctly transform object keys', () => {
@@ -206,15 +198,14 @@ describe('ObjectExpressionKeysTransformer', () => {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/member-expression-host-2.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/member-expression-host-2.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
                         transformObjectKeys: true
                         transformObjectKeys: true
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('should correctly transform object keys', () => {
             it('should correctly transform object keys', () => {
@@ -237,15 +228,14 @@ describe('ObjectExpressionKeysTransformer', () => {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/placement-inside-if-statement.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/placement-inside-if-statement.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
                         transformObjectKeys: true
                         transformObjectKeys: true
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('should correctly transform object keys', () => {
             it('should correctly transform object keys', () => {
@@ -267,15 +257,14 @@ describe('ObjectExpressionKeysTransformer', () => {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/placement-inside-try-statement.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/placement-inside-try-statement.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
                         transformObjectKeys: true
                         transformObjectKeys: true
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('should correctly transform object keys', () => {
             it('should correctly transform object keys', () => {
@@ -297,15 +286,14 @@ describe('ObjectExpressionKeysTransformer', () => {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/placement-inside-catch-clause.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/placement-inside-catch-clause.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
                         transformObjectKeys: true
                         transformObjectKeys: true
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('should correctly transform object keys', () => {
             it('should correctly transform object keys', () => {
@@ -327,15 +315,14 @@ describe('ObjectExpressionKeysTransformer', () => {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/placement-inside-switch-case.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/placement-inside-switch-case.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
                         transformObjectKeys: true
                         transformObjectKeys: true
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('should transform object keys', () => {
             it('should transform object keys', () => {
@@ -356,15 +343,14 @@ describe('ObjectExpressionKeysTransformer', () => {
 
 
                 before(() => {
                 before(() => {
                     const code: string = readFileAsString(__dirname + '/fixtures/variable-declarator-with-object-call-1.js');
                     const code: string = readFileAsString(__dirname + '/fixtures/variable-declarator-with-object-call-1.js');
-                    const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                    obfuscatedCode = JavaScriptObfuscator.obfuscate(
                         code,
                         code,
                         {
                         {
                             ...NO_ADDITIONAL_NODES_PRESET,
                             ...NO_ADDITIONAL_NODES_PRESET,
                             transformObjectKeys: true
                             transformObjectKeys: true
                         }
                         }
-                    );
-
-                    obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                    ).getObfuscatedCode();
                 });
                 });
 
 
                 it('should correctly transform object keys', () => {
                 it('should correctly transform object keys', () => {
@@ -385,15 +371,14 @@ describe('ObjectExpressionKeysTransformer', () => {
 
 
                 before(() => {
                 before(() => {
                     const code: string = readFileAsString(__dirname + '/fixtures/variable-declarator-with-object-call-2.js');
                     const code: string = readFileAsString(__dirname + '/fixtures/variable-declarator-with-object-call-2.js');
-                    const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                    obfuscatedCode = JavaScriptObfuscator.obfuscate(
                         code,
                         code,
                         {
                         {
                             ...NO_ADDITIONAL_NODES_PRESET,
                             ...NO_ADDITIONAL_NODES_PRESET,
                             transformObjectKeys: true
                             transformObjectKeys: true
                         }
                         }
-                    );
-
-                    obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                    ).getObfuscatedCode();
                 });
                 });
 
 
                 it('should correctly transform object keys', () => {
                 it('should correctly transform object keys', () => {
@@ -414,15 +399,14 @@ describe('ObjectExpressionKeysTransformer', () => {
 
 
                 before(() => {
                 before(() => {
                     const code: string = readFileAsString(__dirname + '/fixtures/variable-declarator-with-object-call-3.js');
                     const code: string = readFileAsString(__dirname + '/fixtures/variable-declarator-with-object-call-3.js');
-                    const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                    obfuscatedCode = JavaScriptObfuscator.obfuscate(
                         code,
                         code,
                         {
                         {
                             ...NO_ADDITIONAL_NODES_PRESET,
                             ...NO_ADDITIONAL_NODES_PRESET,
                             transformObjectKeys: true
                             transformObjectKeys: true
                         }
                         }
-                    );
-
-                    obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                    ).getObfuscatedCode();
                 });
                 });
 
 
                 it('should correctly transform first object keys and ignore second object keys', () => {
                 it('should correctly transform first object keys and ignore second object keys', () => {
@@ -446,14 +430,13 @@ describe('ObjectExpressionKeysTransformer', () => {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/simple.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/simple.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET
                         ...NO_ADDITIONAL_NODES_PRESET
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('shouldn\'t transform object keys', () => {
             it('shouldn\'t transform object keys', () => {
@@ -469,14 +452,13 @@ describe('ObjectExpressionKeysTransformer', () => {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/empty-object-expression.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/empty-object-expression.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET
                         ...NO_ADDITIONAL_NODES_PRESET
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('shouldn\'t transform object keys', () => {
             it('shouldn\'t transform object keys', () => {
@@ -496,15 +478,14 @@ describe('ObjectExpressionKeysTransformer', () => {
 
 
                 before(() => {
                 before(() => {
                     const code: string = readFileAsString(__dirname + '/fixtures/variable-declarator-with-object-call-ignore-1.js');
                     const code: string = readFileAsString(__dirname + '/fixtures/variable-declarator-with-object-call-ignore-1.js');
-                    const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                    obfuscatedCode = JavaScriptObfuscator.obfuscate(
                         code,
                         code,
                         {
                         {
                             ...NO_ADDITIONAL_NODES_PRESET,
                             ...NO_ADDITIONAL_NODES_PRESET,
                             transformObjectKeys: true
                             transformObjectKeys: true
                         }
                         }
-                    );
-
-                    obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                    ).getObfuscatedCode();
                 });
                 });
 
 
                 it('shouldn\'t transform object keys', () => {
                 it('shouldn\'t transform object keys', () => {
@@ -523,15 +504,14 @@ describe('ObjectExpressionKeysTransformer', () => {
 
 
                 before(() => {
                 before(() => {
                     const code: string = readFileAsString(__dirname + '/fixtures/variable-declarator-with-object-call-ignore-2.js');
                     const code: string = readFileAsString(__dirname + '/fixtures/variable-declarator-with-object-call-ignore-2.js');
-                    const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                    obfuscatedCode = JavaScriptObfuscator.obfuscate(
                         code,
                         code,
                         {
                         {
                             ...NO_ADDITIONAL_NODES_PRESET,
                             ...NO_ADDITIONAL_NODES_PRESET,
                             transformObjectKeys: true
                             transformObjectKeys: true
                         }
                         }
-                    );
-
-                    obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                    ).getObfuscatedCode();
                 });
                 });
 
 
                 it('shouldn\'t transform object keys', () => {
                 it('shouldn\'t transform object keys', () => {

+ 24 - 34
test/functional-tests/node-transformers/converting-transformers/object-expression-transformer/ObjectExpressionTransformer.spec.ts

@@ -1,7 +1,5 @@
 import { assert } from 'chai';
 import { assert } from 'chai';
 
 
-import { IObfuscationResult } from '../../../../../src/interfaces/IObfuscationResult';
-
 import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes';
 import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes';
 
 
 import { readFileAsString } from '../../../../helpers/readFileAsString';
 import { readFileAsString } from '../../../../helpers/readFileAsString';
@@ -17,15 +15,14 @@ describe('ObjectExpressionTransformer', () => {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/property-with-identifier-value.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/property-with-identifier-value.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
                         unicodeEscapeSequence: false
                         unicodeEscapeSequence: false
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('should replace object expression node `key` property with identifier value by property with literal value', () => {
             it('should replace object expression node `key` property with identifier value by property with literal value', () => {
@@ -40,15 +37,14 @@ describe('ObjectExpressionTransformer', () => {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/property-with-identifier-value.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/property-with-identifier-value.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
                         unicodeEscapeSequence: true
                         unicodeEscapeSequence: true
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('should replace object expression node `key` property with identifier value by property with encoded literal value', () => {
             it('should replace object expression node `key` property with identifier value by property with encoded literal value', () => {
@@ -64,14 +60,13 @@ describe('ObjectExpressionTransformer', () => {
 
 
         before(() => {
         before(() => {
             const code: string = readFileAsString(__dirname + '/fixtures/shorthand-object-expression.js');
             const code: string = readFileAsString(__dirname + '/fixtures/shorthand-object-expression.js');
-            const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+            obfuscatedCode = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET
                     ...NO_ADDITIONAL_NODES_PRESET
                 }
                 }
-            );
-
-            obfuscatedCode = obfuscationResult.getObfuscatedCode();
+            ).getObfuscatedCode();
         });
         });
 
 
         it('should correct convert shorthand ES6 object expression to non-shorthand object expression', () => {
         it('should correct convert shorthand ES6 object expression to non-shorthand object expression', () => {
@@ -87,14 +82,13 @@ describe('ObjectExpressionTransformer', () => {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/computed-property-name-identifier.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/computed-property-name-identifier.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET
                         ...NO_ADDITIONAL_NODES_PRESET
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('should ignore computed property identifier', () => {
             it('should ignore computed property identifier', () => {
@@ -110,15 +104,14 @@ describe('ObjectExpressionTransformer', () => {
 
 
                 before(() => {
                 before(() => {
                     const code: string = readFileAsString(__dirname + '/fixtures/computed-property-name-literal.js');
                     const code: string = readFileAsString(__dirname + '/fixtures/computed-property-name-literal.js');
-                    const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                    obfuscatedCode = JavaScriptObfuscator.obfuscate(
                         code,
                         code,
                         {
                         {
                             ...NO_ADDITIONAL_NODES_PRESET,
                             ...NO_ADDITIONAL_NODES_PRESET,
                             unicodeEscapeSequence: false
                             unicodeEscapeSequence: false
                         }
                         }
-                    );
-
-                    obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                    ).getObfuscatedCode();
                 });
                 });
 
 
                 it('should ignore computed property literal value', () => {
                 it('should ignore computed property literal value', () => {
@@ -133,15 +126,14 @@ describe('ObjectExpressionTransformer', () => {
 
 
                 before(() => {
                 before(() => {
                     const code: string = readFileAsString(__dirname + '/fixtures/computed-property-name-literal.js');
                     const code: string = readFileAsString(__dirname + '/fixtures/computed-property-name-literal.js');
-                    const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                    obfuscatedCode = JavaScriptObfuscator.obfuscate(
                         code,
                         code,
                         {
                         {
                             ...NO_ADDITIONAL_NODES_PRESET,
                             ...NO_ADDITIONAL_NODES_PRESET,
                             unicodeEscapeSequence: true
                             unicodeEscapeSequence: true
                         }
                         }
-                    );
-
-                    obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                    ).getObfuscatedCode();
                 });
                 });
 
 
                 it('should encode computed property literal value', () => {
                 it('should encode computed property literal value', () => {
@@ -159,14 +151,13 @@ describe('ObjectExpressionTransformer', () => {
 
 
         before(() => {
         before(() => {
             const code: string = readFileAsString(__dirname + '/fixtures/object-rest.js');
             const code: string = readFileAsString(__dirname + '/fixtures/object-rest.js');
-            const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+            obfuscatedCode = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET
                     ...NO_ADDITIONAL_NODES_PRESET
                 }
                 }
-            );
-
-            obfuscatedCode = obfuscationResult.getObfuscatedCode();
+            ).getObfuscatedCode();
         });
         });
 
 
         it('Match #1: should transform object name', () => {
         it('Match #1: should transform object name', () => {
@@ -187,14 +178,13 @@ describe('ObjectExpressionTransformer', () => {
 
 
         before(() => {
         before(() => {
             const code: string = readFileAsString(__dirname + '/fixtures/object-spread.js');
             const code: string = readFileAsString(__dirname + '/fixtures/object-spread.js');
-            const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+            obfuscatedCode = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET
                     ...NO_ADDITIONAL_NODES_PRESET
                 }
                 }
-            );
-
-            obfuscatedCode = obfuscationResult.getObfuscatedCode();
+            ).getObfuscatedCode();
         });
         });
 
 
         it('Match #1: should transform object name', () => {
         it('Match #1: should transform object name', () => {

+ 46 - 35
test/functional-tests/node-transformers/converting-transformers/template-literal-transformer/TemplateLiteralTransformer.spec.ts

@@ -1,7 +1,5 @@
 import { assert } from 'chai';
 import { assert } from 'chai';
 
 
-import { IObfuscationResult } from '../../../../../src/interfaces/IObfuscationResult';
-
 import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes';
 import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes';
 
 
 import { readFileAsString } from '../../../../helpers/readFileAsString';
 import { readFileAsString } from '../../../../helpers/readFileAsString';
@@ -9,131 +7,142 @@ import { readFileAsString } from '../../../../helpers/readFileAsString';
 import { JavaScriptObfuscator } from '../../../../../src/JavaScriptObfuscatorFacade';
 import { JavaScriptObfuscator } from '../../../../../src/JavaScriptObfuscatorFacade';
 
 
 describe('TemplateLiteralTransformer', () => {
 describe('TemplateLiteralTransformer', () => {
+    let obfuscatedCode: string;
+    
     describe('Variant #1: simple template literal', () => {
     describe('Variant #1: simple template literal', () => {
         it('should transform es6 template literal to es5', () => {
         it('should transform es6 template literal to es5', () => {
             const code: string = readFileAsString(__dirname + '/fixtures/simple-input.js');
             const code: string = readFileAsString(__dirname + '/fixtures/simple-input.js');
-            const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+            obfuscatedCode = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET,
                     ...NO_ADDITIONAL_NODES_PRESET,
                     unicodeEscapeSequence: false
                     unicodeEscapeSequence: false
                 }
                 }
-            );
+            ).getObfuscatedCode();
 
 
-            assert.match(obfuscationResult.getObfuscatedCode(),  /^var *test *= *'abc\\x20' *\+ *foo;$/);
+            assert.match(obfuscatedCode,  /^var *test *= *'abc\\x20' *\+ *foo;$/);
         });
         });
     });
     });
 
 
     describe('Variant #2: multiline template literals', () => {
     describe('Variant #2: multiline template literals', () => {
         it('Variant #1: should transform es6 multiline template literal to es5', () => {
         it('Variant #1: should transform es6 multiline template literal to es5', () => {
             const code: string = readFileAsString(__dirname + '/fixtures/multiline-template-literal.js');
             const code: string = readFileAsString(__dirname + '/fixtures/multiline-template-literal.js');
-            const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+            obfuscatedCode = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET,
                     ...NO_ADDITIONAL_NODES_PRESET,
                     unicodeEscapeSequence: false
                     unicodeEscapeSequence: false
                 }
                 }
-            );
+            ).getObfuscatedCode();
 
 
-            assert.match(obfuscationResult.getObfuscatedCode(),  /^var *test *= *'foo\\x0abar';$/);
+            assert.match(obfuscatedCode,  /^var *test *= *'foo\\x0abar';$/);
         });
         });
 
 
         it('Variant #2: should transform es6 multiline template literal inside return statement', () => {
         it('Variant #2: should transform es6 multiline template literal inside return statement', () => {
             const code: string = readFileAsString(__dirname + '/fixtures/multiline-template-literal-return-statement-1.js');
             const code: string = readFileAsString(__dirname + '/fixtures/multiline-template-literal-return-statement-1.js');
-            const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+            obfuscatedCode = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET,
                     ...NO_ADDITIONAL_NODES_PRESET,
                     unicodeEscapeSequence: false
                     unicodeEscapeSequence: false
                 }
                 }
-            );
+            ).getObfuscatedCode();
 
 
-            assert.match(obfuscationResult.getObfuscatedCode(),  /{ *return *'foo\\x0abar'; *}$/);
+            assert.match(obfuscatedCode,  /{ *return *'foo\\x0abar'; *}$/);
         });
         });
 
 
         it('Variant #3: should transform es6 multiline template literal inside return statement', () => {
         it('Variant #3: should transform es6 multiline template literal inside return statement', () => {
             const code: string = readFileAsString(__dirname + '/fixtures/multiline-template-literal-return-statement-2.js');
             const code: string = readFileAsString(__dirname + '/fixtures/multiline-template-literal-return-statement-2.js');
-            const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+            obfuscatedCode = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET,
                     ...NO_ADDITIONAL_NODES_PRESET,
                     unicodeEscapeSequence: false
                     unicodeEscapeSequence: false
                 }
                 }
-            );
+            ).getObfuscatedCode();
 
 
-            assert.match(obfuscationResult.getObfuscatedCode(),  /case *!!\[] *: *return *'foo\\x0abar'; *} *}$/);
+            assert.match(obfuscatedCode,  /case *!!\[] *: *return *'foo\\x0abar'; *} *}$/);
         });
         });
 
 
         it('Variant #4: should transform es6 multiline template literal inside binary expression inside return statement', () => {
         it('Variant #4: should transform es6 multiline template literal inside binary expression inside return statement', () => {
             const code: string = readFileAsString(__dirname + '/fixtures/multiline-template-literal-binary-expression-return-statement-1.js');
             const code: string = readFileAsString(__dirname + '/fixtures/multiline-template-literal-binary-expression-return-statement-1.js');
-            const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+            obfuscatedCode = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET,
                     ...NO_ADDITIONAL_NODES_PRESET,
                     unicodeEscapeSequence: false
                     unicodeEscapeSequence: false
                 }
                 }
-            );
+            ).getObfuscatedCode();
 
 
-            assert.match(obfuscationResult.getObfuscatedCode(),  /{ *return *'foo\\x0abar' *\+ *0x1; *}$/);
+            assert.match(obfuscatedCode,  /{ *return *'foo\\x0abar' *\+ *0x1; *}$/);
         });
         });
 
 
         it('Variant #5: should transform es6 multiline template literal inside binary expression inside return statement', () => {
         it('Variant #5: should transform es6 multiline template literal inside binary expression inside return statement', () => {
             const code: string = readFileAsString(__dirname + '/fixtures/multiline-template-literal-binary-expression-return-statement-2.js');
             const code: string = readFileAsString(__dirname + '/fixtures/multiline-template-literal-binary-expression-return-statement-2.js');
-            const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+            obfuscatedCode = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET,
                     ...NO_ADDITIONAL_NODES_PRESET,
                     unicodeEscapeSequence: false
                     unicodeEscapeSequence: false
                 }
                 }
-            );
+            ).getObfuscatedCode();
 
 
-            assert.match(obfuscationResult.getObfuscatedCode(),  /case *!!\[] *: *return *'foo\\x0abar' *\+ *0x1; *} *}$/);
+            assert.match(obfuscatedCode,  /case *!!\[] *: *return *'foo\\x0abar' *\+ *0x1; *} *}$/);
         });
         });
     });
     });
 
 
     describe('Variant #3: simple template literal with expression only', () => {
     describe('Variant #3: simple template literal with expression only', () => {
         it('should transform es6 template literal to es5 and add empty literal node before expression node', () => {
         it('should transform es6 template literal to es5 and add empty literal node before expression node', () => {
             const code: string = readFileAsString(__dirname + '/fixtures/expression-only.js');
             const code: string = readFileAsString(__dirname + '/fixtures/expression-only.js');
-            const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+            obfuscatedCode = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET,
                     ...NO_ADDITIONAL_NODES_PRESET,
                     unicodeEscapeSequence: false
                     unicodeEscapeSequence: false
                 }
                 }
-            );
+            ).getObfuscatedCode();
 
 
-            assert.match(obfuscationResult.getObfuscatedCode(),  /^var *test *= *'' *\+ *foo;$/);
+            assert.match(obfuscatedCode,  /^var *test *= *'' *\+ *foo;$/);
         });
         });
     });
     });
 
 
     describe('Variant #4: literal node inside expression', () => {
     describe('Variant #4: literal node inside expression', () => {
         it('should transform es6 template literal to es5', () => {
         it('should transform es6 template literal to es5', () => {
             const code: string = readFileAsString(__dirname + '/fixtures/literal-inside-expression.js');
             const code: string = readFileAsString(__dirname + '/fixtures/literal-inside-expression.js');
-            const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+            obfuscatedCode = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET,
                     ...NO_ADDITIONAL_NODES_PRESET,
                     unicodeEscapeSequence: false
                     unicodeEscapeSequence: false
                 }
                 }
-            );
+            ).getObfuscatedCode();
 
 
-            assert.match(obfuscationResult.getObfuscatedCode(),  /^var *test *= *'abc';$/);
+            assert.match(obfuscatedCode,  /^var *test *= *'abc';$/);
         });
         });
     });
     });
 
 
     describe('Variant #5: multiple expressions', () => {
     describe('Variant #5: multiple expressions', () => {
         it('should transform es6 template literal to es5', () => {
         it('should transform es6 template literal to es5', () => {
             const code: string = readFileAsString(__dirname + '/fixtures/multiple-expressions.js');
             const code: string = readFileAsString(__dirname + '/fixtures/multiple-expressions.js');
-            const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+            obfuscatedCode = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET,
                     ...NO_ADDITIONAL_NODES_PRESET,
                     unicodeEscapeSequence: false
                     unicodeEscapeSequence: false
                 }
                 }
-            );
+            ).getObfuscatedCode();
 
 
             assert.match(
             assert.match(
-                obfuscationResult.getObfuscatedCode(),
+                obfuscatedCode,
                 /^var *test *= *0x1 *\+ *0x1 *\+ *'\\x20abc\\x20' *\+ *\(0x1 *\+ *0x1\);$/
                 /^var *test *= *0x1 *\+ *0x1 *\+ *'\\x20abc\\x20' *\+ *\(0x1 *\+ *0x1\);$/
             );
             );
         });
         });
@@ -142,16 +151,17 @@ describe('TemplateLiteralTransformer', () => {
     describe('Variant #6: tagged template literal', () => {
     describe('Variant #6: tagged template literal', () => {
         it('shouldn\'t transform es6 tagged template literal to es5', () => {
         it('shouldn\'t transform es6 tagged template literal to es5', () => {
             const code: string = readFileAsString(__dirname + '/fixtures/tagged-template-literal.js');
             const code: string = readFileAsString(__dirname + '/fixtures/tagged-template-literal.js');
-            const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+            obfuscatedCode = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET,
                     ...NO_ADDITIONAL_NODES_PRESET,
                     unicodeEscapeSequence: false
                     unicodeEscapeSequence: false
                 }
                 }
-            );
+            ).getObfuscatedCode();
 
 
             assert.match(
             assert.match(
-                obfuscationResult.getObfuscatedCode(),
+                obfuscatedCode,
                 /tag`foo *\${0x1 *\+ *0x1} *bar`;/
                 /tag`foo *\${0x1 *\+ *0x1} *bar`;/
             );
             );
         });
         });
@@ -160,15 +170,16 @@ describe('TemplateLiteralTransformer', () => {
     describe('Variant #7: template literal parentize', () => {
     describe('Variant #7: template literal parentize', () => {
         it('should parentize transformed template literal node', () => {
         it('should parentize transformed template literal node', () => {
             const code: string = readFileAsString(__dirname + '/fixtures/template-literal-parentize.js');
             const code: string = readFileAsString(__dirname + '/fixtures/template-literal-parentize.js');
-            const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+            obfuscatedCode = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET,
                     ...NO_ADDITIONAL_NODES_PRESET,
                     unicodeEscapeSequence: false
                     unicodeEscapeSequence: false
                 }
                 }
-            );
+            ).getObfuscatedCode();
 
 
-            assert.match(obfuscationResult.getObfuscatedCode(),  /^\[]\['map']\(\(\) *=> *'foo'\);$/);
+            assert.match(obfuscatedCode,  /^\[]\['map']\(\(\) *=> *'foo'\);$/);
         });
         });
     });
     });
 });
 });

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

@@ -1,7 +1,5 @@
 import { assert } from 'chai';
 import { assert } from 'chai';
 
 
-import { IObfuscationResult } from '../../../../src/interfaces/IObfuscationResult';
-
 import { NO_ADDITIONAL_NODES_PRESET } from '../../../../src/options/presets/NoCustomNodes';
 import { NO_ADDITIONAL_NODES_PRESET } from '../../../../src/options/presets/NoCustomNodes';
 
 
 import { IdentifierNamesGenerator } from '../../../../src/enums/generators/identifier-names-generators/IdentifierNamesGenerator';
 import { IdentifierNamesGenerator } from '../../../../src/enums/generators/identifier-names-generators/IdentifierNamesGenerator';
@@ -33,7 +31,8 @@ describe('DeadCodeInjectionTransformer', () => {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/input-1.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/input-1.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                const obfuscatedCode: string = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
@@ -42,8 +41,7 @@ describe('DeadCodeInjectionTransformer', () => {
                         stringArray: true,
                         stringArray: true,
                         stringArrayThreshold: 1
                         stringArrayThreshold: 1
                     }
                     }
-                );
-                const obfuscatedCode: string = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
                 const matches: RegExpMatchArray = <RegExpMatchArray>obfuscatedCode.match(regExp);
                 const matches: RegExpMatchArray = <RegExpMatchArray>obfuscatedCode.match(regExp);
 
 
                 if (matches) {
                 if (matches) {
@@ -69,7 +67,8 @@ describe('DeadCodeInjectionTransformer', () => {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/block-statements-min-count.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/block-statements-min-count.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                const obfuscatedCode: string = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
@@ -78,8 +77,7 @@ describe('DeadCodeInjectionTransformer', () => {
                         stringArray: true,
                         stringArray: true,
                         stringArrayThreshold: 1
                         stringArrayThreshold: 1
                     }
                     }
-                );
-                const obfuscatedCode: string = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
                 const matches: RegExpMatchArray = <RegExpMatchArray>obfuscatedCode.match(regexp);
                 const matches: RegExpMatchArray = <RegExpMatchArray>obfuscatedCode.match(regexp);
 
 
                 if (matches) {
                 if (matches) {
@@ -105,7 +103,8 @@ describe('DeadCodeInjectionTransformer', () => {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/input-1.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/input-1.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                const obfuscatedCode: string = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
@@ -114,8 +113,7 @@ describe('DeadCodeInjectionTransformer', () => {
                         stringArray: true,
                         stringArray: true,
                         stringArrayThreshold: 1
                         stringArrayThreshold: 1
                     }
                     }
-                );
-                const obfuscatedCode: string = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
                 const matches: RegExpMatchArray = <RegExpMatchArray>obfuscatedCode.match(regexp);
                 const matches: RegExpMatchArray = <RegExpMatchArray>obfuscatedCode.match(regexp);
 
 
                 if (matches) {
                 if (matches) {
@@ -149,7 +147,8 @@ describe('DeadCodeInjectionTransformer', () => {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/break-continue-statement.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/break-continue-statement.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                const obfuscatedCode: string = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
@@ -158,8 +157,7 @@ describe('DeadCodeInjectionTransformer', () => {
                         stringArray: true,
                         stringArray: true,
                         stringArrayThreshold: 1
                         stringArrayThreshold: 1
                     }
                     }
-                );
-                const obfuscatedCode: string = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
                 const functionMatches: RegExpMatchArray = <RegExpMatchArray>obfuscatedCode.match(functionRegExp);
                 const functionMatches: RegExpMatchArray = <RegExpMatchArray>obfuscatedCode.match(functionRegExp);
                 const loopMatches: RegExpMatchArray = <RegExpMatchArray>obfuscatedCode.match(loopRegExp);
                 const loopMatches: RegExpMatchArray = <RegExpMatchArray>obfuscatedCode.match(loopRegExp);
 
 
@@ -200,7 +198,8 @@ describe('DeadCodeInjectionTransformer', () => {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/await-expression.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/await-expression.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                const obfuscatedCode: string = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
@@ -209,8 +208,7 @@ describe('DeadCodeInjectionTransformer', () => {
                         stringArray: true,
                         stringArray: true,
                         stringArrayThreshold: 1
                         stringArrayThreshold: 1
                     }
                     }
-                );
-                const obfuscatedCode: string = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
                 const functionMatches: RegExpMatchArray = <RegExpMatchArray>obfuscatedCode.match(functionRegExp);
                 const functionMatches: RegExpMatchArray = <RegExpMatchArray>obfuscatedCode.match(functionRegExp);
                 const awaitExpressionMatches: RegExpMatchArray = <RegExpMatchArray>obfuscatedCode.match(awaitExpressionRegExp);
                 const awaitExpressionMatches: RegExpMatchArray = <RegExpMatchArray>obfuscatedCode.match(awaitExpressionRegExp);
 
 
@@ -251,7 +249,8 @@ describe('DeadCodeInjectionTransformer', () => {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/super-expression.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/super-expression.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                const obfuscatedCode: string = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
@@ -260,8 +259,7 @@ describe('DeadCodeInjectionTransformer', () => {
                         stringArray: true,
                         stringArray: true,
                         stringArrayThreshold: 1
                         stringArrayThreshold: 1
                     }
                     }
-                );
-                const obfuscatedCode: string = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
                 const functionMatches: RegExpMatchArray = <RegExpMatchArray>obfuscatedCode.match(functionRegExp);
                 const functionMatches: RegExpMatchArray = <RegExpMatchArray>obfuscatedCode.match(functionRegExp);
                 const superExpressionMatches: RegExpMatchArray = <RegExpMatchArray>obfuscatedCode.match(superExpressionRegExp);
                 const superExpressionMatches: RegExpMatchArray = <RegExpMatchArray>obfuscatedCode.match(superExpressionRegExp);
 
 
@@ -339,7 +337,8 @@ describe('DeadCodeInjectionTransformer', () => {
                 let count4: number = 0;
                 let count4: number = 0;
 
 
                 for (let i = 0; i < samplesCount; i++) {
                 for (let i = 0; i < samplesCount; i++) {
-                    const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                    const obfuscatedCode: string = JavaScriptObfuscator.obfuscate(
                         code,
                         code,
                         {
                         {
                             ...NO_ADDITIONAL_NODES_PRESET,
                             ...NO_ADDITIONAL_NODES_PRESET,
@@ -348,8 +347,7 @@ describe('DeadCodeInjectionTransformer', () => {
                             stringArray: true,
                             stringArray: true,
                             stringArrayThreshold: 1
                             stringArrayThreshold: 1
                         }
                         }
-                    );
-                    const obfuscatedCode: string = obfuscationResult.getObfuscatedCode();
+                    ).getObfuscatedCode();
 
 
                     if (regExp1.test(obfuscatedCode)) {
                     if (regExp1.test(obfuscatedCode)) {
                         count1++;
                         count1++;
@@ -396,7 +394,8 @@ describe('DeadCodeInjectionTransformer', () => {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/block-scope-is-program-node.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/block-scope-is-program-node.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
@@ -405,9 +404,7 @@ describe('DeadCodeInjectionTransformer', () => {
                         deadCodeInjection: true,
                         deadCodeInjection: true,
                         deadCodeInjectionThreshold: 1
                         deadCodeInjectionThreshold: 1
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('shouldn\'t add dead code in block statements with `ProgramNode` block scope', () => {
             it('shouldn\'t add dead code in block statements with `ProgramNode` block scope', () => {
@@ -422,7 +419,8 @@ describe('DeadCodeInjectionTransformer', () => {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/obfuscation-of-dead-code-block-statements.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/obfuscation-of-dead-code-block-statements.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
@@ -430,9 +428,7 @@ describe('DeadCodeInjectionTransformer', () => {
                         deadCodeInjectionThreshold: 1,
                         deadCodeInjectionThreshold: 1,
                         debugProtection: true
                         debugProtection: true
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('should correctly obfuscate dead-code block statements and prevent any exposing of internal variable names', () => {
             it('should correctly obfuscate dead-code block statements and prevent any exposing of internal variable names', () => {
@@ -528,7 +524,8 @@ describe('DeadCodeInjectionTransformer', () => {
                     for (let i: number = 0; i < 100; i++) {
                     for (let i: number = 0; i < 100; i++) {
                         while (true) {
                         while (true) {
                             try {
                             try {
-                                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                                     code,
                                     code,
                                     {
                                     {
                                         ...NO_ADDITIONAL_NODES_PRESET,
                                         ...NO_ADDITIONAL_NODES_PRESET,
@@ -536,9 +533,7 @@ describe('DeadCodeInjectionTransformer', () => {
                                         deadCodeInjectionThreshold: 1,
                                         deadCodeInjectionThreshold: 1,
                                         identifierNamesGenerator: IdentifierNamesGenerator.MangledIdentifierNamesGenerator
                                         identifierNamesGenerator: IdentifierNamesGenerator.MangledIdentifierNamesGenerator
                                     }
                                     }
-                                );
-
-                                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                                ).getObfuscatedCode();
                                 functionIdentifierName = getRegExpMatch(obfuscatedCode, functionParameterRegExp, 0);
                                 functionIdentifierName = getRegExpMatch(obfuscatedCode, functionParameterRegExp, 0);
                                 variableDeclarationIdentifierName = getRegExpMatch(obfuscatedCode, deadCodeRegExp, 0);
                                 variableDeclarationIdentifierName = getRegExpMatch(obfuscatedCode, deadCodeRegExp, 0);
                                 returnIdentifierName = getRegExpMatch(obfuscatedCode, deadCodeRegExp, 1);
                                 returnIdentifierName = getRegExpMatch(obfuscatedCode, deadCodeRegExp, 1);
@@ -593,7 +588,8 @@ describe('DeadCodeInjectionTransformer', () => {
                     for (let i: number = 0; i < 100; i++) {
                     for (let i: number = 0; i < 100; i++) {
                         while (true) {
                         while (true) {
                             try {
                             try {
-                                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                                     code,
                                     code,
                                     {
                                     {
                                         ...NO_ADDITIONAL_NODES_PRESET,
                                         ...NO_ADDITIONAL_NODES_PRESET,
@@ -601,9 +597,7 @@ describe('DeadCodeInjectionTransformer', () => {
                                         deadCodeInjectionThreshold: 1,
                                         deadCodeInjectionThreshold: 1,
                                         identifierNamesGenerator: IdentifierNamesGenerator.MangledIdentifierNamesGenerator
                                         identifierNamesGenerator: IdentifierNamesGenerator.MangledIdentifierNamesGenerator
                                     }
                                     }
-                                );
-
-                                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                                ).getObfuscatedCode();
                                 functionIdentifierName = getRegExpMatch(obfuscatedCode, functionParameterRegExp, 0);
                                 functionIdentifierName = getRegExpMatch(obfuscatedCode, functionParameterRegExp, 0);
                                 returnIdentifierName = getRegExpMatch(obfuscatedCode, deadCodeRegExp, 0);
                                 returnIdentifierName = getRegExpMatch(obfuscatedCode, deadCodeRegExp, 0);
                                 variableDeclarationIdentifierName = getRegExpMatch(obfuscatedCode, deadCodeRegExp, 1);
                                 variableDeclarationIdentifierName = getRegExpMatch(obfuscatedCode, deadCodeRegExp, 1);
@@ -643,7 +637,8 @@ describe('DeadCodeInjectionTransformer', () => {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/block-statement-empty-body.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/block-statement-empty-body.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                const obfuscatedCode: string = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
@@ -652,9 +647,8 @@ describe('DeadCodeInjectionTransformer', () => {
                         deadCodeInjection: true,
                         deadCodeInjection: true,
                         deadCodeInjectionThreshold: 1
                         deadCodeInjectionThreshold: 1
                     }
                     }
-                );
+                ).getObfuscatedCode();
 
 
-                const obfuscatedCode: string = obfuscationResult.getObfuscatedCode();
                 const functionMatches: RegExpMatchArray = <RegExpMatchArray>obfuscatedCode.match(regExp);
                 const functionMatches: RegExpMatchArray = <RegExpMatchArray>obfuscatedCode.match(regExp);
 
 
                 if (functionMatches) {
                 if (functionMatches) {
@@ -681,7 +675,8 @@ describe('DeadCodeInjectionTransformer', () => {
 
 
                 before(() => {
                 before(() => {
                     const code: string = readFileAsString(__dirname + '/fixtures/block-statement-with-scope-hoisting-1.js');
                     const code: string = readFileAsString(__dirname + '/fixtures/block-statement-with-scope-hoisting-1.js');
-                    const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                    const obfuscatedCode: string = JavaScriptObfuscator.obfuscate(
                         code,
                         code,
                         {
                         {
                             ...NO_ADDITIONAL_NODES_PRESET,
                             ...NO_ADDITIONAL_NODES_PRESET,
@@ -690,9 +685,8 @@ describe('DeadCodeInjectionTransformer', () => {
                             deadCodeInjection: true,
                             deadCodeInjection: true,
                             deadCodeInjectionThreshold: 1
                             deadCodeInjectionThreshold: 1
                         }
                         }
-                    );
+                    ).getObfuscatedCode();
 
 
-                    const obfuscatedCode: string = obfuscationResult.getObfuscatedCode();
                     const functionMatches: RegExpMatchArray = <RegExpMatchArray>obfuscatedCode.match(regExp);
                     const functionMatches: RegExpMatchArray = <RegExpMatchArray>obfuscatedCode.match(regExp);
 
 
                     if (functionMatches) {
                     if (functionMatches) {
@@ -721,7 +715,8 @@ describe('DeadCodeInjectionTransformer', () => {
 
 
                 before(() => {
                 before(() => {
                     const code: string = readFileAsString(__dirname + '/fixtures/block-statement-with-scope-hoisting-2.js');
                     const code: string = readFileAsString(__dirname + '/fixtures/block-statement-with-scope-hoisting-2.js');
-                    const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                    obfuscatedCode = JavaScriptObfuscator.obfuscate(
                         code,
                         code,
                         {
                         {
                             ...NO_ADDITIONAL_NODES_PRESET,
                             ...NO_ADDITIONAL_NODES_PRESET,
@@ -730,9 +725,7 @@ describe('DeadCodeInjectionTransformer', () => {
                             deadCodeInjection: true,
                             deadCodeInjection: true,
                             deadCodeInjectionThreshold: 1
                             deadCodeInjectionThreshold: 1
                         }
                         }
-                    );
-
-                    obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                    ).getObfuscatedCode();
                 });
                 });
 
 
                 it('shouldn\'t wrap block statements in dead code conditions', () => {
                 it('shouldn\'t wrap block statements in dead code conditions', () => {

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

@@ -1,7 +1,5 @@
 import { assert } from 'chai';
 import { assert } from 'chai';
 
 
-import { IObfuscationResult } from '../../../../../src/interfaces/IObfuscationResult';
-
 import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes';
 import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes';
 
 
 import { getRegExpMatch } from '../../../../helpers/getRegExpMatch';
 import { getRegExpMatch } from '../../../../helpers/getRegExpMatch';
@@ -21,14 +19,13 @@ describe('CatchClauseTransformer', () => {
 
 
         before(() => {
         before(() => {
             const code: string = readFileAsString(__dirname + '/fixtures/input.js');
             const code: string = readFileAsString(__dirname + '/fixtures/input.js');
-            const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+            obfuscatedCode = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET
                     ...NO_ADDITIONAL_NODES_PRESET
                 }
                 }
-            );
-
-            obfuscatedCode = obfuscationResult.getObfuscatedCode();
+            ).getObfuscatedCode();
             firstMatch = getRegExpMatch(obfuscatedCode, paramNameRegExp);
             firstMatch = getRegExpMatch(obfuscatedCode, paramNameRegExp);
             secondMatch = getRegExpMatch(obfuscatedCode, bodyParamNameRegExp);
             secondMatch = getRegExpMatch(obfuscatedCode, bodyParamNameRegExp);
         });
         });
@@ -52,14 +49,13 @@ describe('CatchClauseTransformer', () => {
 
 
         before(() => {
         before(() => {
             const code: string = readFileAsString(__dirname + '/fixtures/object-pattern-as-parameter.js');
             const code: string = readFileAsString(__dirname + '/fixtures/object-pattern-as-parameter.js');
-            const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+            obfuscatedCode = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET
                     ...NO_ADDITIONAL_NODES_PRESET
                 }
                 }
-            );
-
-            obfuscatedCode = obfuscationResult.getObfuscatedCode();
+            ).getObfuscatedCode();
         });
         });
 
 
         it('match #1: shouldn\'t transform function parameter object pattern identifier', () => {
         it('match #1: shouldn\'t transform function parameter object pattern identifier', () => {

+ 21 - 30
test/functional-tests/node-transformers/obfuscating-transformers/class-declaration-transformer/ClassDeclarationTransformer.spec.ts

@@ -1,7 +1,5 @@
 import { assert } from 'chai';
 import { assert } from 'chai';
 
 
-import { IObfuscationResult } from '../../../../../src/interfaces/IObfuscationResult';
-
 import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes';
 import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes';
 
 
 import { getRegExpMatch } from '../../../../helpers/getRegExpMatch';
 import { getRegExpMatch } from '../../../../helpers/getRegExpMatch';
@@ -22,14 +20,13 @@ describe('ClassDeclarationTransformer', () => {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/input.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/input.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET
                         ...NO_ADDITIONAL_NODES_PRESET
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
                 classNameIdentifier = getRegExpMatch(obfuscatedCode, classNameIdentifierRegExp);
                 classNameIdentifier = getRegExpMatch(obfuscatedCode, classNameIdentifierRegExp);
                 classCallIdentifier = getRegExpMatch(obfuscatedCode, classCallIdentifierRegExp);
                 classCallIdentifier = getRegExpMatch(obfuscatedCode, classCallIdentifierRegExp);
             });
             });
@@ -48,14 +45,13 @@ describe('ClassDeclarationTransformer', () => {
 
 
                 before(() => {
                 before(() => {
                     const code: string = readFileAsString(__dirname + '/fixtures/parent-block-scope-is-program-node.js');
                     const code: string = readFileAsString(__dirname + '/fixtures/parent-block-scope-is-program-node.js');
-                    const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                    obfuscatedCode = JavaScriptObfuscator.obfuscate(
                         code,
                         code,
                         {
                         {
                             ...NO_ADDITIONAL_NODES_PRESET
                             ...NO_ADDITIONAL_NODES_PRESET
                         }
                         }
-                    );
-
-                    obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                    ).getObfuscatedCode();
                 });
                 });
 
 
                 it('match #1: shouldn\'t transform class name', () => {
                 it('match #1: shouldn\'t transform class name', () => {
@@ -76,15 +72,14 @@ describe('ClassDeclarationTransformer', () => {
 
 
                     before(() => {
                     before(() => {
                         const code: string = readFileAsString(__dirname + '/fixtures/parent-block-scope-is-program-node.js');
                         const code: string = readFileAsString(__dirname + '/fixtures/parent-block-scope-is-program-node.js');
-                        const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                        obfuscatedCode = JavaScriptObfuscator.obfuscate(
                             code,
                             code,
                             {
                             {
                                 ...NO_ADDITIONAL_NODES_PRESET,
                                 ...NO_ADDITIONAL_NODES_PRESET,
                                 renameGlobals: true
                                 renameGlobals: true
                             }
                             }
-                        );
-
-                        obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                        ).getObfuscatedCode();
                     });
                     });
 
 
                     it('match #1: should transform class name', () => {
                     it('match #1: should transform class name', () => {
@@ -104,15 +99,14 @@ describe('ClassDeclarationTransformer', () => {
 
 
                     before(() => {
                     before(() => {
                         const code: string = readFileAsString(__dirname + '/fixtures/rename-globals-identifier-transformation.js');
                         const code: string = readFileAsString(__dirname + '/fixtures/rename-globals-identifier-transformation.js');
-                        const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                        obfuscatedCode = JavaScriptObfuscator.obfuscate(
                             code,
                             code,
                             {
                             {
                                 ...NO_ADDITIONAL_NODES_PRESET,
                                 ...NO_ADDITIONAL_NODES_PRESET,
                                 renameGlobals: true
                                 renameGlobals: true
                             }
                             }
-                        );
-
-                        obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                        ).getObfuscatedCode();
                     });
                     });
 
 
                     it('match #1: should transform identifier name inside class method', () => {
                     it('match #1: should transform identifier name inside class method', () => {
@@ -134,15 +128,14 @@ describe('ClassDeclarationTransformer', () => {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/prevent-renaming-of-renamed-identifiers.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/prevent-renaming-of-renamed-identifiers.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
                         identifierNamesGenerator: IdentifierNamesGenerator.MangledIdentifierNamesGenerator
                         identifierNamesGenerator: IdentifierNamesGenerator.MangledIdentifierNamesGenerator
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('Match #1: shouldn\'t rename twice class declaration name', () => {
             it('Match #1: shouldn\'t rename twice class declaration name', () => {
@@ -161,15 +154,14 @@ describe('ClassDeclarationTransformer', () => {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/named-export.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/named-export.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
                         renameGlobals: true
                         renameGlobals: true
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('shouldn\'t transform identifiers in named export', () => {
             it('shouldn\'t transform identifiers in named export', () => {
@@ -185,15 +177,14 @@ describe('ClassDeclarationTransformer', () => {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/default-export.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/default-export.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
                         renameGlobals: true
                         renameGlobals: true
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('Match #1: should transform identifiers in variable declaration', () => {
             it('Match #1: should transform identifiers in variable declaration', () => {

+ 24 - 34
test/functional-tests/node-transformers/obfuscating-transformers/function-declaration-transformer/FunctionDeclarationTransformer.spec.ts

@@ -1,7 +1,5 @@
 import { assert } from 'chai';
 import { assert } from 'chai';
 
 
-import { IObfuscationResult } from '../../../../../src/interfaces/IObfuscationResult';
-
 import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes';
 import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes';
 
 
 import { getRegExpMatch } from '../../../../helpers/getRegExpMatch';
 import { getRegExpMatch } from '../../../../helpers/getRegExpMatch';
@@ -22,14 +20,13 @@ describe('FunctionDeclarationTransformer', () => {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/input.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/input.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET
                         ...NO_ADDITIONAL_NODES_PRESET
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
                 functionNameIdentifier = getRegExpMatch(obfuscatedCode, functionNameIdentifierRegExp);
                 functionNameIdentifier = getRegExpMatch(obfuscatedCode, functionNameIdentifierRegExp);
                 functionCallIdentifier = getRegExpMatch(obfuscatedCode, functionCallIdentifierRegExp);
                 functionCallIdentifier = getRegExpMatch(obfuscatedCode, functionCallIdentifierRegExp);
             });
             });
@@ -48,14 +45,13 @@ describe('FunctionDeclarationTransformer', () => {
 
 
                 before(() => {
                 before(() => {
                     const code: string = readFileAsString(__dirname + '/fixtures/parent-block-scope-is-program-node.js');
                     const code: string = readFileAsString(__dirname + '/fixtures/parent-block-scope-is-program-node.js');
-                    const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                    obfuscatedCode = JavaScriptObfuscator.obfuscate(
                         code,
                         code,
                         {
                         {
                             ...NO_ADDITIONAL_NODES_PRESET
                             ...NO_ADDITIONAL_NODES_PRESET
                         }
                         }
-                    );
-
-                    obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                    ).getObfuscatedCode();
                 });
                 });
 
 
                 it('match #1: shouldn\'t transform function name', () => {
                 it('match #1: shouldn\'t transform function name', () => {
@@ -75,15 +71,14 @@ describe('FunctionDeclarationTransformer', () => {
 
 
                 before(() => {
                 before(() => {
                     const code: string = readFileAsString(__dirname + '/fixtures/parent-block-scope-is-program-node.js');
                     const code: string = readFileAsString(__dirname + '/fixtures/parent-block-scope-is-program-node.js');
-                    const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                    obfuscatedCode = JavaScriptObfuscator.obfuscate(
                         code,
                         code,
                         {
                         {
                             ...NO_ADDITIONAL_NODES_PRESET,
                             ...NO_ADDITIONAL_NODES_PRESET,
                             renameGlobals: true
                             renameGlobals: true
                         }
                         }
-                    );
-
-                    obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                    ).getObfuscatedCode();
                 });
                 });
 
 
                 it('match #1: should transform function name', () => {
                 it('match #1: should transform function name', () => {
@@ -106,14 +101,13 @@ describe('FunctionDeclarationTransformer', () => {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/generator-function.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/generator-function.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET
                         ...NO_ADDITIONAL_NODES_PRESET
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
                 functionNameIdentifier = getRegExpMatch(obfuscatedCode, functionNameIdentifierRegExp);
                 functionNameIdentifier = getRegExpMatch(obfuscatedCode, functionNameIdentifierRegExp);
                 functionCallIdentifier = getRegExpMatch(obfuscatedCode, functionCallIdentifierRegExp);
                 functionCallIdentifier = getRegExpMatch(obfuscatedCode, functionCallIdentifierRegExp);
             });
             });
@@ -133,14 +127,13 @@ describe('FunctionDeclarationTransformer', () => {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/async-function.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/async-function.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET
                         ...NO_ADDITIONAL_NODES_PRESET
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
                 functionNameIdentifier = getRegExpMatch(obfuscatedCode, functionNameIdentifierRegExp);
                 functionNameIdentifier = getRegExpMatch(obfuscatedCode, functionNameIdentifierRegExp);
                 functionCallIdentifier = getRegExpMatch(obfuscatedCode, functionCallIdentifierRegExp);
                 functionCallIdentifier = getRegExpMatch(obfuscatedCode, functionCallIdentifierRegExp);
             });
             });
@@ -159,15 +152,14 @@ describe('FunctionDeclarationTransformer', () => {
 
 
                 before(() => {
                 before(() => {
                     const code: string = readFileAsString(__dirname + '/fixtures/prevent-renaming-of-renamed-identifiers-1.js');
                     const code: string = readFileAsString(__dirname + '/fixtures/prevent-renaming-of-renamed-identifiers-1.js');
-                    const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                    obfuscatedCode = JavaScriptObfuscator.obfuscate(
                         code,
                         code,
                         {
                         {
                             ...NO_ADDITIONAL_NODES_PRESET,
                             ...NO_ADDITIONAL_NODES_PRESET,
                             identifierNamesGenerator: IdentifierNamesGenerator.MangledIdentifierNamesGenerator
                             identifierNamesGenerator: IdentifierNamesGenerator.MangledIdentifierNamesGenerator
                         }
                         }
-                    );
-
-                    obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                    ).getObfuscatedCode();
                 });
                 });
 
 
                 it('Match #1: shouldn\'t rename twice function declaration name', () => {
                 it('Match #1: shouldn\'t rename twice function declaration name', () => {
@@ -187,15 +179,14 @@ describe('FunctionDeclarationTransformer', () => {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/named-export.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/named-export.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
                         renameGlobals: true
                         renameGlobals: true
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('shouldn\'t transform identifiers in named export', () => {
             it('shouldn\'t transform identifiers in named export', () => {
@@ -211,15 +202,14 @@ describe('FunctionDeclarationTransformer', () => {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/default-export.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/default-export.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
                         renameGlobals: true
                         renameGlobals: true
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('Match #1: should transform identifiers in variable declaration', () => {
             it('Match #1: should transform identifiers in variable declaration', () => {

+ 154 - 42
test/functional-tests/node-transformers/obfuscating-transformers/function-transformer/FunctionTransformer.spec.ts

@@ -1,7 +1,5 @@
 import { assert } from 'chai';
 import { assert } from 'chai';
 
 
-import { IObfuscationResult } from '../../../../../src/interfaces/IObfuscationResult';
-
 import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes';
 import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes';
 
 
 import { readFileAsString } from '../../../../helpers/readFileAsString';
 import { readFileAsString } from '../../../../helpers/readFileAsString';
@@ -21,14 +19,13 @@ describe('FunctionTransformer', () => {
 
 
         before(() => {
         before(() => {
             const code: string = readFileAsString(__dirname + '/fixtures/input.js');
             const code: string = readFileAsString(__dirname + '/fixtures/input.js');
-            const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+            obfuscatedCode = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET
                     ...NO_ADDITIONAL_NODES_PRESET
                 }
                 }
-            );
-
-            obfuscatedCode = obfuscationResult.getObfuscatedCode();
+            ).getObfuscatedCode();
 
 
             const functionParamIdentifierMatch: RegExpMatchArray|null = obfuscatedCode
             const functionParamIdentifierMatch: RegExpMatchArray|null = obfuscatedCode
                 .match(functionParamIdentifierRegExp);
                 .match(functionParamIdentifierRegExp);
@@ -57,14 +54,13 @@ describe('FunctionTransformer', () => {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/object-pattern-as-parameter-1.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/object-pattern-as-parameter-1.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET
                         ...NO_ADDITIONAL_NODES_PRESET
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('match #1: shouldn\'t transform function parameter object pattern identifier', () => {
             it('match #1: shouldn\'t transform function parameter object pattern identifier', () => {
@@ -77,30 +73,75 @@ describe('FunctionTransformer', () => {
         });
         });
 
 
         describe('Variant #2: correct transformation when identifier with same name in parent scope exist', () => {
         describe('Variant #2: correct transformation when identifier with same name in parent scope exist', () => {
+            const functionParameterRegExp: RegExp = /^\(function *\(\) *{ *function *_0x[a-f0-9]{4,6} *\(_0x[a-f0-9]{4,6}\) *\{/;
             const callbackParameterRegExp: RegExp = /\['then'] *\(\({ *data *}\)/;
             const callbackParameterRegExp: RegExp = /\['then'] *\(\({ *data *}\)/;
             const callbackBodyRegExp: RegExp = /console\['log']\(data\)/;
             const callbackBodyRegExp: RegExp = /console\['log']\(data\)/;
+            const returnRegExp: RegExp = /return _0x[a-f0-9]{4,6};/;
 
 
             let obfuscatedCode: string;
             let obfuscatedCode: string;
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/object-pattern-as-parameter-2.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/object-pattern-as-parameter-2.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET
                         ...NO_ADDITIONAL_NODES_PRESET
                     }
                     }
-                );
+                ).getObfuscatedCode();
+            });
 
 
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+            it('match #1: should transform function parameter identifier', () => {
+                assert.match(obfuscatedCode, functionParameterRegExp);
             });
             });
 
 
-            it('match #1: shouldn\'t transform callback parameter object pattern identifier', () => {
+            it('match #2: shouldn\'t transform callback parameter object pattern identifier', () => {
                 assert.match(obfuscatedCode, callbackParameterRegExp);
                 assert.match(obfuscatedCode, callbackParameterRegExp);
             });
             });
 
 
-            it('match #2: shouldn\'t transform callback parameter object pattern identifier', () => {
+            it('match #3: shouldn\'t transform callback body identifier', () => {
                 assert.match(obfuscatedCode, callbackBodyRegExp);
                 assert.match(obfuscatedCode, callbackBodyRegExp);
             });
             });
+
+            it('match #4: should transform identifier in `ReturnStatement`', () => {
+                assert.match(obfuscatedCode, returnRegExp);
+            });
+        });
+
+        describe('Variant #3: correct transformation when parent scope identifier conflicts with current scope object pattern identifier', () => {
+            const functionObjectPatternParameterRegExp1: RegExp = /function _0x[a-f0-9]{4,6} *\({data, *\.\.\._0x[a-f0-9]{4,6}}\) *{/;
+            const functionObjectPatternParameterRegExp2: RegExp = /function _0x[a-f0-9]{4,6} *\({options}\) *{/;
+            const returnRegExp1: RegExp = /return data *\+ *options *\+ *_0x[a-f0-9]{4,6};/;
+            const returnRegExp2: RegExp = /return _0x[a-f0-9]{4,6};/;
+
+            let obfuscatedCode: string;
+
+            before(() => {
+                const code: string = readFileAsString(__dirname + '/fixtures/object-pattern-as-parameter-3.js');
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
+                    code,
+                    {
+                        ...NO_ADDITIONAL_NODES_PRESET
+                    }
+                ).getObfuscatedCode();
+            });
+
+            it('match #1: should transform function parameter object pattern rest identifier', () => {
+                assert.match(obfuscatedCode, functionObjectPatternParameterRegExp1);
+            });
+
+            it('match #2: should transform function parameter object pattern rest identifier', () => {
+                assert.match(obfuscatedCode, functionObjectPatternParameterRegExp2);
+            });
+
+            it('match #3: should transform identifier in `ReturnStatement` of inner function', () => {
+                assert.match(obfuscatedCode, returnRegExp1);
+            });
+
+            it('match #4: should transform identifier in `ReturnStatement` of outer function', () => {
+                assert.match(obfuscatedCode, returnRegExp2);
+            });
         });
         });
     });
     });
 
 
@@ -113,14 +154,13 @@ describe('FunctionTransformer', () => {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/assignment-pattern-as-parameter-1.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/assignment-pattern-as-parameter-1.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET
                         ...NO_ADDITIONAL_NODES_PRESET
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('match #1: should transform function parameter assignment pattern identifier', () => {
             it('match #1: should transform function parameter assignment pattern identifier', () => {
@@ -145,14 +185,13 @@ describe('FunctionTransformer', () => {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/assignment-pattern-as-parameter-2.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/assignment-pattern-as-parameter-2.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET
                         ...NO_ADDITIONAL_NODES_PRESET
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
                 variableDeclarationIdentifierName = getRegExpMatch(obfuscatedCode, variableDeclarationRegExp);
                 variableDeclarationIdentifierName = getRegExpMatch(obfuscatedCode, variableDeclarationRegExp);
                 functionParameterIdentifierName = getRegExpMatch(obfuscatedCode, functionParameterRegExp);
                 functionParameterIdentifierName = getRegExpMatch(obfuscatedCode, functionParameterRegExp);
                 functionDefaultParameterIdentifierName = getRegExpMatch(obfuscatedCode, functionParameterRegExp, 1);
                 functionDefaultParameterIdentifierName = getRegExpMatch(obfuscatedCode, functionParameterRegExp, 1);
@@ -195,14 +234,13 @@ describe('FunctionTransformer', () => {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/assignment-pattern-as-parameter-3.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/assignment-pattern-as-parameter-3.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET
                         ...NO_ADDITIONAL_NODES_PRESET
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
 
 
                 variableDeclarationIdentifierName = getRegExpMatch(obfuscatedCode, variableDeclarationRegExp);
                 variableDeclarationIdentifierName = getRegExpMatch(obfuscatedCode, variableDeclarationRegExp);
                 functionParameterIdentifierName = getRegExpMatch(obfuscatedCode, functionParameterRegExp);
                 functionParameterIdentifierName = getRegExpMatch(obfuscatedCode, functionParameterRegExp);
@@ -262,13 +300,13 @@ describe('FunctionTransformer', () => {
 
 
         before(() => {
         before(() => {
             const code: string = readFileAsString(__dirname + '/fixtures/array-pattern-as-parameter.js');
             const code: string = readFileAsString(__dirname + '/fixtures/array-pattern-as-parameter.js');
-            const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+            const obfuscatedCode: string = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET
                     ...NO_ADDITIONAL_NODES_PRESET
                 }
                 }
-            );
-            const obfuscatedCode: string = obfuscationResult.getObfuscatedCode();
+            ).getObfuscatedCode();
 
 
             arrayPatternIdentifierName1 = getRegExpMatch(obfuscatedCode, functionParameterRegExp);
             arrayPatternIdentifierName1 = getRegExpMatch(obfuscatedCode, functionParameterRegExp);
             arrayPatternIdentifierName2 = getRegExpMatch(obfuscatedCode, functionParameterRegExp, 1);
             arrayPatternIdentifierName2 = getRegExpMatch(obfuscatedCode, functionParameterRegExp, 1);
@@ -293,14 +331,13 @@ describe('FunctionTransformer', () => {
 
 
         before(() => {
         before(() => {
             const code: string = readFileAsString(__dirname + '/fixtures/rest-parameter.js');
             const code: string = readFileAsString(__dirname + '/fixtures/rest-parameter.js');
-            const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+            obfuscatedCode = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET
                     ...NO_ADDITIONAL_NODES_PRESET
                 }
                 }
-            );
-
-            obfuscatedCode = obfuscationResult.getObfuscatedCode();
+            ).getObfuscatedCode();
         });
         });
 
 
         it('Match #1: should transform function rest parameter', () => {
         it('Match #1: should transform function rest parameter', () => {
@@ -320,14 +357,13 @@ describe('FunctionTransformer', () => {
 
 
         before(() => {
         before(() => {
             const code: string = readFileAsString(__dirname + '/fixtures/array-rest-parameter.js');
             const code: string = readFileAsString(__dirname + '/fixtures/array-rest-parameter.js');
-            const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+            obfuscatedCode = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET
                     ...NO_ADDITIONAL_NODES_PRESET
                 }
                 }
-            );
-
-            obfuscatedCode = obfuscationResult.getObfuscatedCode();
+            ).getObfuscatedCode();
         });
         });
 
 
         it('Match #1: should transform function rest parameter', () => {
         it('Match #1: should transform function rest parameter', () => {
@@ -347,14 +383,13 @@ describe('FunctionTransformer', () => {
 
 
         before(() => {
         before(() => {
             const code: string = readFileAsString(__dirname + '/fixtures/object-rest-parameter.js');
             const code: string = readFileAsString(__dirname + '/fixtures/object-rest-parameter.js');
-            const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+            obfuscatedCode = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET
                     ...NO_ADDITIONAL_NODES_PRESET
                 }
                 }
-            );
-
-            obfuscatedCode = obfuscationResult.getObfuscatedCode();
+            ).getObfuscatedCode();
         });
         });
 
 
         it('Match #1: should transform function rest parameter', () => {
         it('Match #1: should transform function rest parameter', () => {
@@ -365,4 +400,81 @@ describe('FunctionTransformer', () => {
             assert.match(obfuscatedCode, returnRegExp);
             assert.match(obfuscatedCode, returnRegExp);
         });
         });
     });
     });
+
+    describe('ignored identifier names set', () => {
+        describe('Variant #1: avoid to add `ObjectPattern` identifier to the set when same identifier exist in function parameter', () => {
+            const functionBodyRegExp: RegExp = /\[]\['find']\(\({bar: *_0x[a-f0-9]{4,6}}\) *=> *_0x[a-f0-9]{4,6}\);/;
+
+            let obfuscatedCode: string;
+
+            before(() => {
+                const code: string = readFileAsString(__dirname + '/fixtures/identifier-names-set-object-pattern.js');
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
+                    code,
+                    {
+                        ...NO_ADDITIONAL_NODES_PRESET
+                    }
+                ).getObfuscatedCode();
+            });
+
+            it('should transform identifiers in function body', () => {
+                assert.match(obfuscatedCode, functionBodyRegExp);
+            });
+        });
+    });
+
+    describe('correct block scope detection of arrow function expression', () => {
+        describe('Variant #1: block statement body', () => {
+            const regExpMatch: string = `` +
+                `\\[]` +
+                `\\['map']\\(_0x[a-f0-9]{4,6} *=> *\\{ *return 0x1; *\\}\\)` +
+                `\\['map']\\(_0x[a-f0-9]{4,6} *=> *\\[foo]\\);` +
+            ``;
+            const regExp: RegExp = new RegExp(regExpMatch);
+
+            let obfuscatedCode: string;
+
+            before(() => {
+                const code: string = readFileAsString(__dirname + '/fixtures/arrow-function-with-expression-body-block-scope-detection-1.js');
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
+                    code,
+                    {
+                        ...NO_ADDITIONAL_NODES_PRESET
+                    }
+                ).getObfuscatedCode();
+            });
+
+            it('should transform identifiers in arrow function expression body', () => {
+                assert.match(obfuscatedCode, regExp);
+            });
+        });
+
+        describe('Variant #2: expression statement body', () => {
+            const regExpMatch: string = `` +
+                `\\[]` +
+                `\\['map']\\(_0x[a-f0-9]{4,6} *=> *0x1\\)` +
+                `\\['map']\\(_0x[a-f0-9]{4,6} *=> *\\[foo]\\);` +
+            ``;
+            const regExp: RegExp = new RegExp(regExpMatch);
+
+            let obfuscatedCode: string;
+
+            before(() => {
+                const code: string = readFileAsString(__dirname + '/fixtures/arrow-function-with-expression-body-block-scope-detection-2.js');
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
+                    code,
+                    {
+                        ...NO_ADDITIONAL_NODES_PRESET
+                    }
+                ).getObfuscatedCode();
+            });
+
+            it('should transform identifiers in arrow function expression body', () => {
+                assert.match(obfuscatedCode, regExp);
+            });
+        });
+    });
 });
 });

+ 6 - 0
test/functional-tests/node-transformers/obfuscating-transformers/function-transformer/fixtures/arrow-function-with-expression-body-block-scope-detection-1.js

@@ -0,0 +1,6 @@
+const foo = 1;
+[]
+    .map(foo => {
+        return 1;
+    })
+    .map(bar => [foo]);

+ 4 - 0
test/functional-tests/node-transformers/obfuscating-transformers/function-transformer/fixtures/arrow-function-with-expression-body-block-scope-detection-2.js

@@ -0,0 +1,4 @@
+const foo = 1;
+[]
+    .map(foo => 1)
+    .map(bar => [foo]);

+ 3 - 0
test/functional-tests/node-transformers/obfuscating-transformers/function-transformer/fixtures/identifier-names-set-object-pattern.js

@@ -0,0 +1,3 @@
+function foo(bar) {
+    [].find(({bar: baz}) => bar);
+}

+ 1 - 0
test/functional-tests/node-transformers/obfuscating-transformers/function-transformer/fixtures/object-pattern-as-parameter-2.js

@@ -2,6 +2,7 @@
     function foo (data) {
     function foo (data) {
         new Promise((resolve) => resolve({data: data}))
         new Promise((resolve) => resolve({data: data}))
             .then(({data}) => console.log(data));
             .then(({data}) => console.log(data));
+        return data;
     }
     }
 
 
     foo(1);
     foo(1);

+ 11 - 0
test/functional-tests/node-transformers/obfuscating-transformers/function-transformer/fixtures/object-pattern-as-parameter-3.js

@@ -0,0 +1,11 @@
+(function(){
+    function foo (data, options) {
+        function bar ({data, ...rest}) {
+            function baz ({options}) {
+                return data + options + rest;
+            }
+        }
+
+        return data;
+    }
+})();

+ 15 - 22
test/functional-tests/node-transformers/obfuscating-transformers/impot-declaration-transformer/ImportDeclarationTransformer.spec.ts

@@ -1,7 +1,5 @@
 import { assert } from 'chai';
 import { assert } from 'chai';
 
 
-import { IObfuscationResult } from '../../../../../src/interfaces/IObfuscationResult';
-
 import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes';
 import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes';
 
 
 import { getRegExpMatch } from '../../../../helpers/getRegExpMatch';
 import { getRegExpMatch } from '../../../../helpers/getRegExpMatch';
@@ -21,14 +19,13 @@ describe('ImportDeclarationTransformer', () => {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/default-import.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/default-import.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET
                         ...NO_ADDITIONAL_NODES_PRESET
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
                 importSpecifierIdentifier = getRegExpMatch(obfuscatedCode, importSpecifierRegExp);
                 importSpecifierIdentifier = getRegExpMatch(obfuscatedCode, importSpecifierRegExp);
                 consoleLogIdentifier = getRegExpMatch(obfuscatedCode, consoleLogRegExp);
                 consoleLogIdentifier = getRegExpMatch(obfuscatedCode, consoleLogRegExp);
             });
             });
@@ -48,14 +45,13 @@ describe('ImportDeclarationTransformer', () => {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/namespace-import.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/namespace-import.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET
                         ...NO_ADDITIONAL_NODES_PRESET
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
                 importSpecifierIdentifier = getRegExpMatch(obfuscatedCode, importSpecifierRegExp);
                 importSpecifierIdentifier = getRegExpMatch(obfuscatedCode, importSpecifierRegExp);
                 consoleLogIdentifier = getRegExpMatch(obfuscatedCode, consoleLogRegExp);
                 consoleLogIdentifier = getRegExpMatch(obfuscatedCode, consoleLogRegExp);
             });
             });
@@ -74,14 +70,13 @@ describe('ImportDeclarationTransformer', () => {
 
 
                 before(() => {
                 before(() => {
                     const code: string = readFileAsString(__dirname + '/fixtures/named-import-1.js');
                     const code: string = readFileAsString(__dirname + '/fixtures/named-import-1.js');
-                    const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                    obfuscatedCode = JavaScriptObfuscator.obfuscate(
                         code,
                         code,
                         {
                         {
                             ...NO_ADDITIONAL_NODES_PRESET
                             ...NO_ADDITIONAL_NODES_PRESET
                         }
                         }
-                    );
-
-                    obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                    ).getObfuscatedCode();
                 });
                 });
 
 
                 it('Match #1: shouldn\'t transform import specifier identifier name', () => {
                 it('Match #1: shouldn\'t transform import specifier identifier name', () => {
@@ -103,14 +98,13 @@ describe('ImportDeclarationTransformer', () => {
 
 
                 before(() => {
                 before(() => {
                     const code: string = readFileAsString(__dirname + '/fixtures/named-import-2.js');
                     const code: string = readFileAsString(__dirname + '/fixtures/named-import-2.js');
-                    const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                    obfuscatedCode = JavaScriptObfuscator.obfuscate(
                         code,
                         code,
                         {
                         {
                             ...NO_ADDITIONAL_NODES_PRESET
                             ...NO_ADDITIONAL_NODES_PRESET
                         }
                         }
-                    );
-
-                    obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                    ).getObfuscatedCode();
                     importSpecifierIdentifier = getRegExpMatch(obfuscatedCode, importSpecifierRegExp);
                     importSpecifierIdentifier = getRegExpMatch(obfuscatedCode, importSpecifierRegExp);
                     consoleLogIdentifier = getRegExpMatch(obfuscatedCode, consoleLogRegExp);
                     consoleLogIdentifier = getRegExpMatch(obfuscatedCode, consoleLogRegExp);
                 });
                 });
@@ -131,15 +125,14 @@ describe('ImportDeclarationTransformer', () => {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/namespace-import.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/namespace-import.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
                         identifiersPrefix: 'bark'
                         identifiersPrefix: 'bark'
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
                 importSpecifierIdentifier = getRegExpMatch(obfuscatedCode, importSpecifierRegExp);
                 importSpecifierIdentifier = getRegExpMatch(obfuscatedCode, importSpecifierRegExp);
                 consoleLogIdentifier = getRegExpMatch(obfuscatedCode, consoleLogRegExp);
                 consoleLogIdentifier = getRegExpMatch(obfuscatedCode, consoleLogRegExp);
             });
             });

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

@@ -1,7 +1,5 @@
 import { assert } from 'chai';
 import { assert } from 'chai';
 
 
-import { IObfuscationResult } from '../../../../../src/interfaces/IObfuscationResult';
-
 import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes';
 import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes';
 
 
 import { getRegExpMatch } from '../../../../helpers/getRegExpMatch';
 import { getRegExpMatch } from '../../../../helpers/getRegExpMatch';
@@ -22,14 +20,13 @@ describe('LabeledStatementTransformer', () => {
 
 
         before(() => {
         before(() => {
             const code: string = readFileAsString(__dirname + '/fixtures/input.js');
             const code: string = readFileAsString(__dirname + '/fixtures/input.js');
-            const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+            obfuscatedCode = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET
                     ...NO_ADDITIONAL_NODES_PRESET
                 }
                 }
-            );
-
-            obfuscatedCode = obfuscationResult.getObfuscatedCode();
+            ).getObfuscatedCode();
 
 
             firstMatch = getRegExpMatch(obfuscatedCode, labeledStatementRegExp);
             firstMatch = getRegExpMatch(obfuscatedCode, labeledStatementRegExp);
             secondMatch = getRegExpMatch(obfuscatedCode, continueStatementRegExp);
             secondMatch = getRegExpMatch(obfuscatedCode, continueStatementRegExp);

+ 56 - 76
test/functional-tests/node-transformers/obfuscating-transformers/literal-transformer/LiteralTransformer.spec.ts

@@ -1,7 +1,5 @@
 import { assert } from 'chai';
 import { assert } from 'chai';
 
 
-import { IObfuscationResult } from '../../../../../src/interfaces/IObfuscationResult';
-
 import { IdentifierNamesGenerator } from '../../../../../src/enums/generators/identifier-names-generators/IdentifierNamesGenerator';
 import { IdentifierNamesGenerator } from '../../../../../src/enums/generators/identifier-names-generators/IdentifierNamesGenerator';
 import { StringArrayEncoding } from '../../../../../src/enums/StringArrayEncoding';
 import { StringArrayEncoding } from '../../../../../src/enums/StringArrayEncoding';
 
 
@@ -21,16 +19,15 @@ describe('LiteralTransformer', () => {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/simple-input.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/simple-input.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
                         stringArray: true,
                         stringArray: true,
                         stringArrayThreshold: 1
                         stringArrayThreshold: 1
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('match #1: should replace literal node value with value from string array', () => {
             it('match #1: should replace literal node value with value from string array', () => {
@@ -49,14 +46,13 @@ describe('LiteralTransformer', () => {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/simple-input.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/simple-input.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET
                         ...NO_ADDITIONAL_NODES_PRESET
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('shouldn\'t replace literal node value with value from string array', () => {
             it('shouldn\'t replace literal node value with value from string array', () => {
@@ -93,16 +89,15 @@ describe('LiteralTransformer', () => {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/same-literal-values.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/same-literal-values.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
                         stringArray: true,
                         stringArray: true,
                         stringArrayThreshold: 1
                         stringArrayThreshold: 1
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('match #1: should create only one item in string array for same literal node values', () => {
             it('match #1: should create only one item in string array for same literal node values', () => {
@@ -121,16 +116,15 @@ describe('LiteralTransformer', () => {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/simple-input.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/simple-input.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
                         unicodeEscapeSequence: true
                         unicodeEscapeSequence: true
 
 
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('should replace literal node value with unicode escape sequence', () => {
             it('should replace literal node value with unicode escape sequence', () => {
@@ -146,7 +140,8 @@ describe('LiteralTransformer', () => {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/simple-input.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/simple-input.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
@@ -154,9 +149,7 @@ describe('LiteralTransformer', () => {
                         stringArrayThreshold: 1,
                         stringArrayThreshold: 1,
                         unicodeEscapeSequence: true
                         unicodeEscapeSequence: true
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('match #1: should replace literal node value with unicode escape sequence from string array', () => {
             it('match #1: should replace literal node value with unicode escape sequence from string array', () => {
@@ -175,16 +168,15 @@ describe('LiteralTransformer', () => {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/short-literal-value.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/short-literal-value.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
                         stringArray: true,
                         stringArray: true,
                         stringArrayThreshold: 1
                         stringArrayThreshold: 1
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('shouldn\'t replace short literal node value with value from string array', () => {
             it('shouldn\'t replace short literal node value with value from string array', () => {
@@ -200,7 +192,8 @@ describe('LiteralTransformer', () => {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/simple-input.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/simple-input.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
@@ -208,9 +201,7 @@ describe('LiteralTransformer', () => {
                         stringArrayEncoding: StringArrayEncoding.Base64,
                         stringArrayEncoding: StringArrayEncoding.Base64,
                         stringArrayThreshold: 1
                         stringArrayThreshold: 1
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('match #1: should replace literal node value with value from string array encoded using base64', () => {
             it('match #1: should replace literal node value with value from string array encoded using base64', () => {
@@ -229,7 +220,8 @@ describe('LiteralTransformer', () => {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/simple-input.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/simple-input.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
@@ -237,9 +229,7 @@ describe('LiteralTransformer', () => {
                         stringArrayEncoding: StringArrayEncoding.Rc4,
                         stringArrayEncoding: StringArrayEncoding.Rc4,
                         stringArrayThreshold: 1
                         stringArrayThreshold: 1
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('should replace literal node value with value from string array encoded using rc4', () => {
             it('should replace literal node value with value from string array encoded using rc4', () => {
@@ -260,21 +250,20 @@ describe('LiteralTransformer', () => {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/simple-input.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/simple-input.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                const obfuscatedCode: string = JavaScriptObfuscator.obfuscate(
                     `${code}\n`.repeat(samples),
                     `${code}\n`.repeat(samples),
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
                         stringArray: true,
                         stringArray: true,
                         stringArrayThreshold: stringArrayThreshold
                         stringArrayThreshold: stringArrayThreshold
                     }
                     }
-                );
+                ).getObfuscatedCode();
 
 
-                const stringArrayMatchesLength: number = obfuscationResult
-                    .getObfuscatedCode()
+                const stringArrayMatchesLength: number = obfuscatedCode
                     .match(regExp1)!
                     .match(regExp1)!
                     .length;
                     .length;
-                const noStringArrayMatchesLength: number = obfuscationResult
-                    .getObfuscatedCode()
+                const noStringArrayMatchesLength: number = obfuscatedCode
                     .match(regExp2)!
                     .match(regExp2)!
                     .length;
                     .length;
 
 
@@ -298,7 +287,8 @@ describe('LiteralTransformer', () => {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/string-array-calls-wrapper-name.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/string-array-calls-wrapper-name.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
@@ -306,9 +296,7 @@ describe('LiteralTransformer', () => {
                         stringArrayThreshold: 1,
                         stringArrayThreshold: 1,
                         identifierNamesGenerator: IdentifierNamesGenerator.MangledIdentifierNamesGenerator
                         identifierNamesGenerator: IdentifierNamesGenerator.MangledIdentifierNamesGenerator
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('match #1: should keep identifier with string array calls wrapper name untouched after obfuscation', () => {
             it('match #1: should keep identifier with string array calls wrapper name untouched after obfuscation', () => {
@@ -326,7 +314,8 @@ describe('LiteralTransformer', () => {
 
 
                     before(() => {
                     before(() => {
                         const code: string = readFileAsString(__dirname + '/fixtures/reserved-strings-option.js');
                         const code: string = readFileAsString(__dirname + '/fixtures/reserved-strings-option.js');
-                        const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                        obfuscatedCode = JavaScriptObfuscator.obfuscate(
                             code,
                             code,
                             {
                             {
                                 ...NO_ADDITIONAL_NODES_PRESET,
                                 ...NO_ADDITIONAL_NODES_PRESET,
@@ -334,9 +323,7 @@ describe('LiteralTransformer', () => {
                                 stringArrayThreshold: 1,
                                 stringArrayThreshold: 1,
                                 reservedStrings: ['foo']
                                 reservedStrings: ['foo']
                             }
                             }
-                        );
-
-                        obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                        ).getObfuscatedCode();
                     });
                     });
 
 
                     it('match #1: should ignore reserved strings', () => {
                     it('match #1: should ignore reserved strings', () => {
@@ -356,7 +343,8 @@ describe('LiteralTransformer', () => {
 
 
                     before(() => {
                     before(() => {
                         const code: string = readFileAsString(__dirname + '/fixtures/reserved-strings-option.js');
                         const code: string = readFileAsString(__dirname + '/fixtures/reserved-strings-option.js');
-                        const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                        obfuscatedCode = JavaScriptObfuscator.obfuscate(
                             code,
                             code,
                             {
                             {
                                 ...NO_ADDITIONAL_NODES_PRESET,
                                 ...NO_ADDITIONAL_NODES_PRESET,
@@ -364,9 +352,7 @@ describe('LiteralTransformer', () => {
                                 stringArrayThreshold: 1,
                                 stringArrayThreshold: 1,
                                 reservedStrings: ['foo', 'bar']
                                 reservedStrings: ['foo', 'bar']
                             }
                             }
-                        );
-
-                        obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                        ).getObfuscatedCode();
                     });
                     });
 
 
                     it('match #1: should ignore reserved strings', () => {
                     it('match #1: should ignore reserved strings', () => {
@@ -388,7 +374,8 @@ describe('LiteralTransformer', () => {
 
 
                     before(() => {
                     before(() => {
                         const code: string = readFileAsString(__dirname + '/fixtures/reserved-strings-option.js');
                         const code: string = readFileAsString(__dirname + '/fixtures/reserved-strings-option.js');
-                        const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                        obfuscatedCode = JavaScriptObfuscator.obfuscate(
                             code,
                             code,
                             {
                             {
                                 ...NO_ADDITIONAL_NODES_PRESET,
                                 ...NO_ADDITIONAL_NODES_PRESET,
@@ -396,9 +383,7 @@ describe('LiteralTransformer', () => {
                                 stringArrayThreshold: 1,
                                 stringArrayThreshold: 1,
                                 reservedStrings: ['ar$']
                                 reservedStrings: ['ar$']
                             }
                             }
-                        );
-
-                        obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                        ).getObfuscatedCode();
                     });
                     });
 
 
                     it('match #1: should transform non-reserved strings', () => {
                     it('match #1: should transform non-reserved strings', () => {
@@ -418,7 +403,8 @@ describe('LiteralTransformer', () => {
 
 
                     before(() => {
                     before(() => {
                         const code: string = readFileAsString(__dirname + '/fixtures/reserved-strings-option.js');
                         const code: string = readFileAsString(__dirname + '/fixtures/reserved-strings-option.js');
-                        const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                        obfuscatedCode = JavaScriptObfuscator.obfuscate(
                             code,
                             code,
                             {
                             {
                                 ...NO_ADDITIONAL_NODES_PRESET,
                                 ...NO_ADDITIONAL_NODES_PRESET,
@@ -426,9 +412,7 @@ describe('LiteralTransformer', () => {
                                 stringArrayThreshold: 1,
                                 stringArrayThreshold: 1,
                                 reservedStrings: ['^fo', '.ar']
                                 reservedStrings: ['^fo', '.ar']
                             }
                             }
-                        );
-
-                        obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                        ).getObfuscatedCode();
                     });
                     });
 
 
                     it('match #1: should ignore reserved strings', () => {
                     it('match #1: should ignore reserved strings', () => {
@@ -449,16 +433,15 @@ describe('LiteralTransformer', () => {
 
 
                 before(() => {
                 before(() => {
                     const code: string = readFileAsString(__dirname + '/fixtures/reserved-strings-option.js');
                     const code: string = readFileAsString(__dirname + '/fixtures/reserved-strings-option.js');
-                    const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                    obfuscatedCode = JavaScriptObfuscator.obfuscate(
                         code,
                         code,
                         {
                         {
                             ...NO_ADDITIONAL_NODES_PRESET,
                             ...NO_ADDITIONAL_NODES_PRESET,
                             reservedStrings: ['foo'],
                             reservedStrings: ['foo'],
                             unicodeEscapeSequence: true
                             unicodeEscapeSequence: true
                         }
                         }
-                    );
-
-                    obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                    ).getObfuscatedCode();
                 });
                 });
 
 
                 it('match #1: should ignore reserved strings', () => {
                 it('match #1: should ignore reserved strings', () => {
@@ -479,16 +462,15 @@ describe('LiteralTransformer', () => {
 
 
         before(() => {
         before(() => {
             const code: string = readFileAsString(__dirname + '/fixtures/boolean-value.js');
             const code: string = readFileAsString(__dirname + '/fixtures/boolean-value.js');
-            const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+            obfuscatedCode = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET,
                     ...NO_ADDITIONAL_NODES_PRESET,
                     stringArray: true,
                     stringArray: true,
                     stringArrayThreshold: 1
                     stringArrayThreshold: 1
                 }
                 }
-            );
-
-            obfuscatedCode = obfuscationResult.getObfuscatedCode();
+            ).getObfuscatedCode();
         });
         });
 
 
         it('should transform literal node', () => {
         it('should transform literal node', () => {
@@ -503,16 +485,15 @@ describe('LiteralTransformer', () => {
 
 
         before(() => {
         before(() => {
             const code: string = readFileAsString(__dirname + '/fixtures/number-value.js');
             const code: string = readFileAsString(__dirname + '/fixtures/number-value.js');
-            const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+            obfuscatedCode = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET,
                     ...NO_ADDITIONAL_NODES_PRESET,
                     stringArray: true,
                     stringArray: true,
                     stringArrayThreshold: 1
                     stringArrayThreshold: 1
                 }
                 }
-            );
-
-            obfuscatedCode = obfuscationResult.getObfuscatedCode();
+            ).getObfuscatedCode();
         });
         });
 
 
         it('should transform literal node', () => {
         it('should transform literal node', () => {
@@ -527,16 +508,15 @@ describe('LiteralTransformer', () => {
 
 
         before(() => {
         before(() => {
             const code: string = readFileAsString(__dirname + '/fixtures/regexp-literal.js');
             const code: string = readFileAsString(__dirname + '/fixtures/regexp-literal.js');
-            const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+            obfuscatedCode = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET,
                     ...NO_ADDITIONAL_NODES_PRESET,
                     stringArray: true,
                     stringArray: true,
                     stringArrayThreshold: 1
                     stringArrayThreshold: 1
                 }
                 }
-            );
-
-            obfuscatedCode = obfuscationResult.getObfuscatedCode();
+            ).getObfuscatedCode();
         });
         });
 
 
         it('should keep safe value of RegExp literal', () => {
         it('should keep safe value of RegExp literal', () => {

+ 60 - 80
test/functional-tests/node-transformers/obfuscating-transformers/variable-declaration-transformer/VariableDeclarationTransformer.spec.ts

@@ -1,7 +1,5 @@
 import { assert } from 'chai';
 import { assert } from 'chai';
 
 
-import { IObfuscationResult } from '../../../../../src/interfaces/IObfuscationResult';
-
 import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes';
 import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes';
 
 
 import { getRegExpMatch } from '../../../../helpers/getRegExpMatch';
 import { getRegExpMatch } from '../../../../helpers/getRegExpMatch';
@@ -20,14 +18,13 @@ describe('VariableDeclarationTransformer', () => {
 
 
         before(() => {
         before(() => {
             const code: string = readFileAsString(__dirname + '/fixtures/simple-declaration.js');
             const code: string = readFileAsString(__dirname + '/fixtures/simple-declaration.js');
-            const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+            obfuscatedCode = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET
                     ...NO_ADDITIONAL_NODES_PRESET
                 }
                 }
-            );
-
-            obfuscatedCode = obfuscationResult.getObfuscatedCode();
+            ).getObfuscatedCode();
         });
         });
 
 
         it('match #1: should transform `variableDeclaration` node', () => {
         it('match #1: should transform `variableDeclaration` node', () => {
@@ -48,14 +45,13 @@ describe('VariableDeclarationTransformer', () => {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/parent-block-scope-is-program-node.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/parent-block-scope-is-program-node.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET
                         ...NO_ADDITIONAL_NODES_PRESET
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('match #1: shouldn\'t transform `variableDeclaration` node', () => {
             it('match #1: shouldn\'t transform `variableDeclaration` node', () => {
@@ -75,15 +71,14 @@ describe('VariableDeclarationTransformer', () => {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/parent-block-scope-is-program-node.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/parent-block-scope-is-program-node.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
                         renameGlobals: true
                         renameGlobals: true
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('match #1: should transform `variableDeclaration` node', () => {
             it('match #1: should transform `variableDeclaration` node', () => {
@@ -103,14 +98,13 @@ describe('VariableDeclarationTransformer', () => {
 
 
         before(() => {
         before(() => {
             const code: string = readFileAsString(__dirname + '/fixtures/var-kind.js');
             const code: string = readFileAsString(__dirname + '/fixtures/var-kind.js');
-            const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+            obfuscatedCode = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET
                     ...NO_ADDITIONAL_NODES_PRESET
                 }
                 }
-            );
-
-            obfuscatedCode = obfuscationResult.getObfuscatedCode();
+            ).getObfuscatedCode();
         });
         });
 
 
         it('should transform variable call (`identifier` node) outside of block scope of node in which this variable was declared with `var` kind', () => {
         it('should transform variable call (`identifier` node) outside of block scope of node in which this variable was declared with `var` kind', () => {
@@ -125,14 +119,13 @@ describe('VariableDeclarationTransformer', () => {
 
 
         before(() => {
         before(() => {
             const code: string = readFileAsString(__dirname + '/fixtures/let-kind.js');
             const code: string = readFileAsString(__dirname + '/fixtures/let-kind.js');
-            const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+            obfuscatedCode = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET
                     ...NO_ADDITIONAL_NODES_PRESET
                 }
                 }
-            );
-
-            obfuscatedCode = obfuscationResult.getObfuscatedCode();
+            ).getObfuscatedCode();
         });
         });
 
 
         it('shouldn\'t transform variable call (`identifier` node) outside of block scope of node in which this variable was declared with `let` kind', () => {
         it('shouldn\'t transform variable call (`identifier` node) outside of block scope of node in which this variable was declared with `let` kind', () => {
@@ -148,14 +141,13 @@ describe('VariableDeclarationTransformer', () => {
 
 
         before(() => {
         before(() => {
             const code: string = readFileAsString(__dirname + '/fixtures/variable-call-before-variable-declaration-1.js');
             const code: string = readFileAsString(__dirname + '/fixtures/variable-call-before-variable-declaration-1.js');
-            const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+            obfuscatedCode = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET
                     ...NO_ADDITIONAL_NODES_PRESET
                 }
                 }
-            );
-
-            obfuscatedCode = obfuscationResult.getObfuscatedCode();
+            ).getObfuscatedCode();
         });
         });
 
 
         it('should transform variable call (`identifier` node name) before variable declaration if this call is inside function body', () => {
         it('should transform variable call (`identifier` node name) before variable declaration if this call is inside function body', () => {
@@ -182,13 +174,13 @@ describe('VariableDeclarationTransformer', () => {
 
 
         before(() => {
         before(() => {
             const code: string = readFileAsString(__dirname + '/fixtures/variable-call-before-variable-declaration-2.js');
             const code: string = readFileAsString(__dirname + '/fixtures/variable-call-before-variable-declaration-2.js');
-            const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+            const obfuscatedCode: string = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET
                     ...NO_ADDITIONAL_NODES_PRESET
                 }
                 }
-            );
-            const obfuscatedCode: string = obfuscationResult.getObfuscatedCode();
+            ).getObfuscatedCode();
 
 
             outerFunctionParamIdentifierName = getRegExpMatch(obfuscatedCode, functionParamIdentifierRegExp);
             outerFunctionParamIdentifierName = getRegExpMatch(obfuscatedCode, functionParamIdentifierRegExp);
             innerFunctionParamIdentifierName = getRegExpMatch(obfuscatedCode, innerFunctionParamIdentifierRegExp);
             innerFunctionParamIdentifierName = getRegExpMatch(obfuscatedCode, innerFunctionParamIdentifierRegExp);
@@ -237,13 +229,13 @@ describe('VariableDeclarationTransformer', () => {
 
 
         before(() => {
         before(() => {
             const code: string = readFileAsString(__dirname + '/fixtures/variable-call-before-variable-declaration-3.js');
             const code: string = readFileAsString(__dirname + '/fixtures/variable-call-before-variable-declaration-3.js');
-            const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+            const obfuscatedCode: string = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET
                     ...NO_ADDITIONAL_NODES_PRESET
                 }
                 }
-            );
-            const obfuscatedCode: string = obfuscationResult.getObfuscatedCode();
+            ).getObfuscatedCode();
 
 
             catchClauseParamIdentifierName = getRegExpMatch(obfuscatedCode, catchClauseParamIdentifierRegExp);
             catchClauseParamIdentifierName = getRegExpMatch(obfuscatedCode, catchClauseParamIdentifierRegExp);
             innerFunctionParamIdentifierName = getRegExpMatch(obfuscatedCode, innerFunctionParamIdentifierRegExp);
             innerFunctionParamIdentifierName = getRegExpMatch(obfuscatedCode, innerFunctionParamIdentifierRegExp);
@@ -285,14 +277,13 @@ describe('VariableDeclarationTransformer', () => {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/property-identifier.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/property-identifier.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET
                         ...NO_ADDITIONAL_NODES_PRESET
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('shouldn\'t replace property node identifier', () => {
             it('shouldn\'t replace property node identifier', () => {
@@ -307,14 +298,13 @@ describe('VariableDeclarationTransformer', () => {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/member-expression-identifier.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/member-expression-identifier.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET
                         ...NO_ADDITIONAL_NODES_PRESET
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('shouldn\'t replace computed member expression identifier', () => {
             it('shouldn\'t replace computed member expression identifier', () => {
@@ -331,14 +321,13 @@ describe('VariableDeclarationTransformer', () => {
 
 
         before(() => {
         before(() => {
             const code: string = readFileAsString(__dirname + '/fixtures/object-pattern.js');
             const code: string = readFileAsString(__dirname + '/fixtures/object-pattern.js');
-            const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+            obfuscatedCode = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET
                     ...NO_ADDITIONAL_NODES_PRESET
                 }
                 }
-            );
-
-            obfuscatedCode = obfuscationResult.getObfuscatedCode();
+            ).getObfuscatedCode();
         });
         });
 
 
         it('match #1: shouldn\'t transform object pattern variable declarator', () => {
         it('match #1: shouldn\'t transform object pattern variable declarator', () => {
@@ -362,14 +351,13 @@ describe('VariableDeclarationTransformer', () => {
 
 
         before(() => {
         before(() => {
             const code: string = readFileAsString(__dirname + '/fixtures/array-pattern.js');
             const code: string = readFileAsString(__dirname + '/fixtures/array-pattern.js');
-            const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+            obfuscatedCode = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET
                     ...NO_ADDITIONAL_NODES_PRESET
                 }
                 }
-            );
-
-            obfuscatedCode = obfuscationResult.getObfuscatedCode();
+            ).getObfuscatedCode();
 
 
             objectPatternIdentifierName1 = getRegExpMatch(obfuscatedCode, objectPatternVariableDeclaratorRegExp);
             objectPatternIdentifierName1 = getRegExpMatch(obfuscatedCode, objectPatternVariableDeclaratorRegExp);
             objectPatternIdentifierName2 = getRegExpMatch(obfuscatedCode, objectPatternVariableDeclaratorRegExp, 1);
             objectPatternIdentifierName2 = getRegExpMatch(obfuscatedCode, objectPatternVariableDeclaratorRegExp, 1);
@@ -401,14 +389,13 @@ describe('VariableDeclarationTransformer', () => {
 
 
         before(() => {
         before(() => {
             const code: string = readFileAsString(__dirname + '/fixtures/computed-object-expression-identifier.js');
             const code: string = readFileAsString(__dirname + '/fixtures/computed-object-expression-identifier.js');
-            const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+            obfuscatedCode = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET
                     ...NO_ADDITIONAL_NODES_PRESET
                 }
                 }
-            );
-
-            obfuscatedCode = obfuscationResult.getObfuscatedCode();
+            ).getObfuscatedCode();
         });
         });
 
 
         it('should transform computed object expression identifier', () => {
         it('should transform computed object expression identifier', () => {
@@ -423,14 +410,13 @@ describe('VariableDeclarationTransformer', () => {
 
 
         before(() => {
         before(() => {
             const code: string = readFileAsString(__dirname + '/fixtures/method-definition-identifier.js');
             const code: string = readFileAsString(__dirname + '/fixtures/method-definition-identifier.js');
-            const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+            obfuscatedCode = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET
                     ...NO_ADDITIONAL_NODES_PRESET
                 }
                 }
-            );
-
-            obfuscatedCode = obfuscationResult.getObfuscatedCode();
+            ).getObfuscatedCode();
         });
         });
 
 
         it('shouldn\'t transform method definition node key identifier', () => {
         it('shouldn\'t transform method definition node key identifier', () => {
@@ -450,15 +436,14 @@ describe('VariableDeclarationTransformer', () => {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/prevent-renaming-of-renamed-identifiers-1.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/prevent-renaming-of-renamed-identifiers-1.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
                         identifierNamesGenerator: IdentifierNamesGenerator.MangledIdentifierNamesGenerator
                         identifierNamesGenerator: IdentifierNamesGenerator.MangledIdentifierNamesGenerator
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('Match #1: shouldn\'t rename twice variable declaration name', () => {
             it('Match #1: shouldn\'t rename twice variable declaration name', () => {
@@ -492,15 +477,14 @@ describe('VariableDeclarationTransformer', () => {
 
 
             before(() => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/prevent-renaming-of-renamed-identifiers-2.js');
                 const code: string = readFileAsString(__dirname + '/fixtures/prevent-renaming-of-renamed-identifiers-2.js');
-                const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
                     code,
                     code,
                     {
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         ...NO_ADDITIONAL_NODES_PRESET,
                         identifierNamesGenerator: IdentifierNamesGenerator.MangledIdentifierNamesGenerator
                         identifierNamesGenerator: IdentifierNamesGenerator.MangledIdentifierNamesGenerator
                     }
                     }
-                );
-
-                obfuscatedCode = obfuscationResult.getObfuscatedCode();
+                ).getObfuscatedCode();
             });
             });
 
 
             it('Match #1: shouldn\'t rename twice variable declaration name', () => {
             it('Match #1: shouldn\'t rename twice variable declaration name', () => {
@@ -528,15 +512,14 @@ describe('VariableDeclarationTransformer', () => {
 
 
         before(() => {
         before(() => {
             const code: string = readFileAsString(__dirname + '/fixtures/named-export.js');
             const code: string = readFileAsString(__dirname + '/fixtures/named-export.js');
-            const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+            obfuscatedCode = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET,
                     ...NO_ADDITIONAL_NODES_PRESET,
                     renameGlobals: true
                     renameGlobals: true
                 }
                 }
-            );
-
-            obfuscatedCode = obfuscationResult.getObfuscatedCode();
+            ).getObfuscatedCode();
         });
         });
 
 
         it('shouldn\'t transform identifiers in named export', () => {
         it('shouldn\'t transform identifiers in named export', () => {
@@ -552,15 +535,14 @@ describe('VariableDeclarationTransformer', () => {
 
 
         before(() => {
         before(() => {
             const code: string = readFileAsString(__dirname + '/fixtures/default-export.js');
             const code: string = readFileAsString(__dirname + '/fixtures/default-export.js');
-            const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+            obfuscatedCode = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET,
                     ...NO_ADDITIONAL_NODES_PRESET,
                     renameGlobals: true
                     renameGlobals: true
                 }
                 }
-            );
-
-            obfuscatedCode = obfuscationResult.getObfuscatedCode();
+            ).getObfuscatedCode();
         });
         });
 
 
         it('Match #1: should transform identifiers in variable declaration', () => {
         it('Match #1: should transform identifiers in variable declaration', () => {
@@ -580,14 +562,13 @@ describe('VariableDeclarationTransformer', () => {
 
 
         before(() => {
         before(() => {
             const code: string = readFileAsString(__dirname + '/fixtures/array-rest.js');
             const code: string = readFileAsString(__dirname + '/fixtures/array-rest.js');
-            const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+            obfuscatedCode = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET
                     ...NO_ADDITIONAL_NODES_PRESET
                 }
                 }
-            );
-
-            obfuscatedCode = obfuscationResult.getObfuscatedCode();
+            ).getObfuscatedCode();
         });
         });
 
 
         it('Match #1: should transform object name', () => {
         it('Match #1: should transform object name', () => {
@@ -607,14 +588,13 @@ describe('VariableDeclarationTransformer', () => {
 
 
         before(() => {
         before(() => {
             const code: string = readFileAsString(__dirname + '/fixtures/object-rest.js');
             const code: string = readFileAsString(__dirname + '/fixtures/object-rest.js');
-            const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+            obfuscatedCode = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET
                     ...NO_ADDITIONAL_NODES_PRESET
                 }
                 }
-            );
-
-            obfuscatedCode = obfuscationResult.getObfuscatedCode();
+            ).getObfuscatedCode();
         });
         });
 
 
         it('Match #1: should transform object name', () => {
         it('Match #1: should transform object name', () => {

+ 18 - 26
test/functional-tests/node-transformers/preparing-transformers/comments-transformer/CommentsTransformer.spec.ts

@@ -1,7 +1,5 @@
 import { assert } from 'chai';
 import { assert } from 'chai';
 
 
-import { IObfuscationResult } from '../../../../../src/interfaces/IObfuscationResult';
-
 import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes';
 import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes';
 
 
 import { readFileAsString } from '../../../../helpers/readFileAsString';
 import { readFileAsString } from '../../../../helpers/readFileAsString';
@@ -16,14 +14,13 @@ describe('CommentsTransformer', () => {
 
 
         before(() => {
         before(() => {
             const code: string = readFileAsString(__dirname + '/fixtures/no-preserved-words.js');
             const code: string = readFileAsString(__dirname + '/fixtures/no-preserved-words.js');
-            const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+            obfuscatedCode = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET
                     ...NO_ADDITIONAL_NODES_PRESET
                 }
                 }
-            );
-
-            obfuscatedCode = obfuscationResult.getObfuscatedCode();
+            ).getObfuscatedCode();
         });
         });
 
 
         it('should remove comments without preserved words', () => {
         it('should remove comments without preserved words', () => {
@@ -38,14 +35,13 @@ describe('CommentsTransformer', () => {
 
 
         before(() => {
         before(() => {
             const code: string = readFileAsString(__dirname + '/fixtures/preserved-words.js');
             const code: string = readFileAsString(__dirname + '/fixtures/preserved-words.js');
-            const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+            obfuscatedCode = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET
                     ...NO_ADDITIONAL_NODES_PRESET
                 }
                 }
-            );
-
-            obfuscatedCode = obfuscationResult.getObfuscatedCode();
+            ).getObfuscatedCode();
         });
         });
 
 
         it('should keep comments with preserved words', () => {
         it('should keep comments with preserved words', () => {
@@ -60,14 +56,13 @@ describe('CommentsTransformer', () => {
 
 
         before(() => {
         before(() => {
             const code: string = readFileAsString(__dirname + '/fixtures/combined-words-1.js');
             const code: string = readFileAsString(__dirname + '/fixtures/combined-words-1.js');
-            const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+            obfuscatedCode = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET
                     ...NO_ADDITIONAL_NODES_PRESET
                 }
                 }
-            );
-
-            obfuscatedCode = obfuscationResult.getObfuscatedCode();
+            ).getObfuscatedCode();
         });
         });
 
 
         it('should keep comments with preserved words', () => {
         it('should keep comments with preserved words', () => {
@@ -89,14 +84,13 @@ describe('CommentsTransformer', () => {
 
 
         before(() => {
         before(() => {
             const code: string = readFileAsString(__dirname + '/fixtures/combined-words-2.js');
             const code: string = readFileAsString(__dirname + '/fixtures/combined-words-2.js');
-            const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+            obfuscatedCode = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET
                     ...NO_ADDITIONAL_NODES_PRESET
                 }
                 }
-            );
-
-            obfuscatedCode = obfuscationResult.getObfuscatedCode();
+            ).getObfuscatedCode();
         });
         });
 
 
         it('should keep comments with preserved words', () => {
         it('should keep comments with preserved words', () => {
@@ -109,14 +103,13 @@ describe('CommentsTransformer', () => {
 
 
         before(() => {
         before(() => {
             const code: string = readFileAsString(__dirname + '/fixtures/comments-only-1.js');
             const code: string = readFileAsString(__dirname + '/fixtures/comments-only-1.js');
-            const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+            obfuscatedCode = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET
                     ...NO_ADDITIONAL_NODES_PRESET
                 }
                 }
-            );
-
-            obfuscatedCode = obfuscationResult.getObfuscatedCode();
+            ).getObfuscatedCode();
         });
         });
 
 
         it('should remove comment without preserved words', () => {
         it('should remove comment without preserved words', () => {
@@ -131,14 +124,13 @@ describe('CommentsTransformer', () => {
 
 
         before(() => {
         before(() => {
             const code: string = readFileAsString(__dirname + '/fixtures/comments-only-2.js');
             const code: string = readFileAsString(__dirname + '/fixtures/comments-only-2.js');
-            const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+            obfuscatedCode = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET
                     ...NO_ADDITIONAL_NODES_PRESET
                 }
                 }
-            );
-
-            obfuscatedCode = obfuscationResult.getObfuscatedCode();
+            ).getObfuscatedCode();
         });
         });
 
 
         it('should keep comments with preserved words', () => {
         it('should keep comments with preserved words', () => {

+ 27 - 38
test/functional-tests/node-transformers/preparing-transformers/eval-call-expression-transformer/EvalCallExpressionTransformer.spec.ts

@@ -1,7 +1,5 @@
 import { assert } from 'chai';
 import { assert } from 'chai';
 
 
-import { IObfuscationResult } from '../../../../../src/interfaces/IObfuscationResult';
-
 import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes';
 import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes';
 
 
 import { readFileAsString } from '../../../../helpers/readFileAsString';
 import { readFileAsString } from '../../../../helpers/readFileAsString';
@@ -20,14 +18,13 @@ describe('EvalCallExpressionTransformer', () => {
 
 
         before(() => {
         before(() => {
             const code: string = readFileAsString(__dirname + '/fixtures/identifier-reference.js');
             const code: string = readFileAsString(__dirname + '/fixtures/identifier-reference.js');
-            const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+            obfuscatedCode = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET
                     ...NO_ADDITIONAL_NODES_PRESET
                 }
                 }
-            );
-
-            obfuscatedCode = obfuscationResult.getObfuscatedCode();
+            ).getObfuscatedCode();
 
 
             functionIdentifierName = getRegExpMatch(obfuscatedCode, functionIdentifierRegExp);
             functionIdentifierName = getRegExpMatch(obfuscatedCode, functionIdentifierRegExp);
             variableReferenceIdentifierName = getRegExpMatch(obfuscatedCode, evalExpressionRegExp);
             variableReferenceIdentifierName = getRegExpMatch(obfuscatedCode, evalExpressionRegExp);
@@ -52,14 +49,13 @@ describe('EvalCallExpressionTransformer', () => {
 
 
         before(() => {
         before(() => {
             const code: string = readFileAsString(__dirname + '/fixtures/call-expression-identifier-reference.js');
             const code: string = readFileAsString(__dirname + '/fixtures/call-expression-identifier-reference.js');
-            const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+            obfuscatedCode = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET
                     ...NO_ADDITIONAL_NODES_PRESET
                 }
                 }
-            );
-
-            obfuscatedCode = obfuscationResult.getObfuscatedCode();
+            ).getObfuscatedCode();
 
 
             functionIdentifierName = getRegExpMatch(obfuscatedCode, functionIdentifierRegExp);
             functionIdentifierName = getRegExpMatch(obfuscatedCode, functionIdentifierRegExp);
             variableReferenceIdentifierName = getRegExpMatch(obfuscatedCode, evalExpressionRegExp);
             variableReferenceIdentifierName = getRegExpMatch(obfuscatedCode, evalExpressionRegExp);
@@ -81,14 +77,13 @@ describe('EvalCallExpressionTransformer', () => {
 
 
         before(() => {
         before(() => {
             const code: string = readFileAsString(__dirname + '/fixtures/multiple-statements-eval.js');
             const code: string = readFileAsString(__dirname + '/fixtures/multiple-statements-eval.js');
-            const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+            obfuscatedCode = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET
                     ...NO_ADDITIONAL_NODES_PRESET
                 }
                 }
-            );
-
-            obfuscatedCode = obfuscationResult.getObfuscatedCode();
+            ).getObfuscatedCode();
         });
         });
 
 
         it('should obfuscate eval string', () => {
         it('should obfuscate eval string', () => {
@@ -104,16 +99,15 @@ describe('EvalCallExpressionTransformer', () => {
 
 
         before(() => {
         before(() => {
             const code: string = readFileAsString(__dirname + '/fixtures/string-array-calls-wrapper-call.js');
             const code: string = readFileAsString(__dirname + '/fixtures/string-array-calls-wrapper-call.js');
-            const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+            obfuscatedCode = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET,
                     ...NO_ADDITIONAL_NODES_PRESET,
                     stringArray: true,
                     stringArray: true,
                     stringArrayThreshold: 1
                     stringArrayThreshold: 1
                 }
                 }
-            );
-
-            obfuscatedCode = obfuscationResult.getObfuscatedCode();
+            ).getObfuscatedCode();
         });
         });
 
 
         it('match #1: should add strings from eval expression to the string array', () => {
         it('match #1: should add strings from eval expression to the string array', () => {
@@ -135,14 +129,13 @@ describe('EvalCallExpressionTransformer', () => {
 
 
         before(() => {
         before(() => {
             const code: string = readFileAsString(__dirname + '/fixtures/eval-expression-as-argument.js');
             const code: string = readFileAsString(__dirname + '/fixtures/eval-expression-as-argument.js');
-            const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+            obfuscatedCode = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET
                     ...NO_ADDITIONAL_NODES_PRESET
                 }
                 }
-            );
-
-            obfuscatedCode = obfuscationResult.getObfuscatedCode();
+            ).getObfuscatedCode();
 
 
             functionIdentifierName = getRegExpMatch(obfuscatedCode, functionIdentifierRegExp);
             functionIdentifierName = getRegExpMatch(obfuscatedCode, functionIdentifierRegExp);
             variableReferenceIdentifierName = getRegExpMatch(obfuscatedCode, evalExpressionRegExp);
             variableReferenceIdentifierName = getRegExpMatch(obfuscatedCode, evalExpressionRegExp);
@@ -182,14 +175,13 @@ describe('EvalCallExpressionTransformer', () => {
 
 
         before(() => {
         before(() => {
             const code: string = readFileAsString(__dirname + '/fixtures/nested-eval-expressions.js');
             const code: string = readFileAsString(__dirname + '/fixtures/nested-eval-expressions.js');
-            const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+            obfuscatedCode = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET
                     ...NO_ADDITIONAL_NODES_PRESET
                 }
                 }
-            );
-
-            obfuscatedCode = obfuscationResult.getObfuscatedCode();
+            ).getObfuscatedCode();
 
 
             functionIdentifierAName = getRegExpMatch(obfuscatedCode, functionIdentifierRegExp, 0);
             functionIdentifierAName = getRegExpMatch(obfuscatedCode, functionIdentifierRegExp, 0);
             functionIdentifierBName = getRegExpMatch(obfuscatedCode, functionIdentifierRegExp, 1);
             functionIdentifierBName = getRegExpMatch(obfuscatedCode, functionIdentifierRegExp, 1);
@@ -240,14 +232,13 @@ describe('EvalCallExpressionTransformer', () => {
 
 
         before(() => {
         before(() => {
             const code: string = readFileAsString(__dirname + '/fixtures/wrong-eval-string.js');
             const code: string = readFileAsString(__dirname + '/fixtures/wrong-eval-string.js');
-            const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+            obfuscatedCode = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET
                     ...NO_ADDITIONAL_NODES_PRESET
                 }
                 }
-            );
-
-            obfuscatedCode = obfuscationResult.getObfuscatedCode();
+            ).getObfuscatedCode();
         });
         });
 
 
         it('should skip obfuscation of eval string', () => {
         it('should skip obfuscation of eval string', () => {
@@ -265,14 +256,13 @@ describe('EvalCallExpressionTransformer', () => {
 
 
         before(() => {
         before(() => {
             const code: string = readFileAsString(__dirname + '/fixtures/eval-expression-template-literal.js');
             const code: string = readFileAsString(__dirname + '/fixtures/eval-expression-template-literal.js');
-            const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+            obfuscatedCode = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET
                     ...NO_ADDITIONAL_NODES_PRESET
                 }
                 }
-            );
-
-            obfuscatedCode = obfuscationResult.getObfuscatedCode();
+            ).getObfuscatedCode();
 
 
             functionIdentifierName = getRegExpMatch(obfuscatedCode, functionIdentifierRegExp);
             functionIdentifierName = getRegExpMatch(obfuscatedCode, functionIdentifierRegExp);
             variableReferenceIdentifierName = getRegExpMatch(obfuscatedCode, evalExpressionRegExp);
             variableReferenceIdentifierName = getRegExpMatch(obfuscatedCode, evalExpressionRegExp);
@@ -303,16 +293,15 @@ describe('EvalCallExpressionTransformer', () => {
 
 
         before(() => {
         before(() => {
             const code: string = readFileAsString(__dirname + '/fixtures/control-flow-flattening-integration.js');
             const code: string = readFileAsString(__dirname + '/fixtures/control-flow-flattening-integration.js');
-            const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
+
+            obfuscatedCode = JavaScriptObfuscator.obfuscate(
                 code,
                 code,
                 {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET,
                     ...NO_ADDITIONAL_NODES_PRESET,
                     controlFlowFlattening: true,
                     controlFlowFlattening: true,
                     controlFlowFlatteningThreshold: 1
                     controlFlowFlatteningThreshold: 1
                 }
                 }
-            );
-
-            obfuscatedCode = obfuscationResult.getObfuscatedCode();
+            ).getObfuscatedCode();
         });
         });
 
 
         it('should add control flow storage node', () => {
         it('should add control flow storage node', () => {

Niektóre pliki nie zostały wyświetlone z powodu dużej ilości zmienionych plików