Browse Source

Simplified initialization of nameSequence for MangledIdentifierNamesGenerator

sanex3339 4 years ago
parent
commit
9c6ce86446

File diff suppressed because it is too large
+ 0 - 0
dist/index.browser.js


File diff suppressed because it is too large
+ 0 - 0
dist/index.cli.js


File diff suppressed because it is too large
+ 0 - 0
dist/index.js


+ 9 - 24
src/generators/identifier-names-generators/MangledIdentifierNamesGenerator.ts

@@ -1,9 +1,8 @@
-import { inject, injectable, postConstruct } from 'inversify';
+import { inject, injectable } from 'inversify';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 
 import { TNodeWithLexicalScope } from '../../types/node/TNodeWithLexicalScope';
 
-import { IInitializable } from '../../interfaces/IInitializable';
 import { IOptions } from '../../interfaces/options/IOptions';
 import { IRandomGenerator } from '../../interfaces/utils/IRandomGenerator';
 
@@ -15,12 +14,7 @@ import { AbstractIdentifierNamesGenerator } from './AbstractIdentifierNamesGener
 import { NodeLexicalScopeUtils } from '../../node/NodeLexicalScopeUtils';
 
 @injectable()
-export class MangledIdentifierNamesGenerator extends AbstractIdentifierNamesGenerator implements IInitializable {
-    /**
-     * @type {string[]}
-     */
-    protected static nameSequence: string[];
-
+export class MangledIdentifierNamesGenerator extends AbstractIdentifierNamesGenerator {
     /**
      * @type {string}
      */
@@ -31,6 +25,13 @@ export class MangledIdentifierNamesGenerator extends AbstractIdentifierNamesGene
      */
     private static readonly lastMangledNameInScopeMap: WeakMap <TNodeWithLexicalScope, string> = new WeakMap();
 
+    /**
+     * @type {string[]}
+     */
+    private static readonly nameSequence: string[] = [
+        ...`${numbersString}${alphabetString}${alphabetStringUppercase}`
+    ];
+
     /**
      * Reserved JS words with length of 2-4 symbols that can be possible generated with this replacer
      *
@@ -58,13 +59,6 @@ export class MangledIdentifierNamesGenerator extends AbstractIdentifierNamesGene
         super(randomGenerator, options);
     }
 
-    @postConstruct()
-    public initialize (): void {
-        this.initializeNameSequence([
-            ...`${numbersString}${alphabetString}${alphabetStringUppercase}`
-        ]);
-    }
-
     /**
      * We can only ignore limited nameLength, it has no sense here
      * @param {number} nameLength
@@ -136,15 +130,6 @@ export class MangledIdentifierNamesGenerator extends AbstractIdentifierNamesGene
             && !MangledIdentifierNamesGenerator.reservedNamesSet.has(mangledName);
     }
 
-    /**
-     * @param {string[]} nameSequence
-     */
-    protected initializeNameSequence (nameSequence: string[]): void {
-        if (!this.getNameSequence()) {
-            MangledIdentifierNamesGenerator.nameSequence = nameSequence;
-        }
-    }
-
     /**
      * @returns {string[]}
      */

Some files were not shown because too many files changed in this diff