Skip to content

Commit

Permalink
Simplified initialization of nameSequence for MangledIdentifierNamesG…
Browse files Browse the repository at this point in the history
…enerator
  • Loading branch information
sanex3339 committed Jul 10, 2020
1 parent d074bbe commit 9c6ce86
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 27 deletions.
2 changes: 1 addition & 1 deletion dist/index.browser.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.cli.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -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}
*/
Expand All @@ -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
*
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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[]}
*/
Expand Down

0 comments on commit 9c6ce86

Please sign in to comment.