javascript-obfuscator
Version:
JavaScript obfuscator
69 lines (55 loc) • 2.44 kB
text/typescript
import { inject, injectable } from 'inversify';
import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
import { TNodeWithLexicalScopeStatements } from '../../types/node/TNodeWithLexicalScopeStatements';
import { IArrayUtils } from '../../interfaces/utils/IArrayUtils';
import { IOptions } from '../../interfaces/options/IOptions';
import { IRandomGenerator } from '../../interfaces/utils/IRandomGenerator';
import { IVisitedLexicalScopeNodesStackStorage } from '../../interfaces/storages/string-array-transformers/IVisitedLexicalScopeNodesStackStorage';
import { ArrayStorage } from '../ArrayStorage';
()
export class VisitedLexicalScopeNodesStackStorage extends ArrayStorage <TNodeWithLexicalScopeStatements> implements IVisitedLexicalScopeNodesStackStorage {
/**
* @type {IArrayUtils}
*/
private readonly arrayUtils: IArrayUtils;
/**
* @param {IRandomGenerator} randomGenerator
* @param {IOptions} options
* @param {IArrayUtils} arrayUtils
*/
public constructor (
(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
(ServiceIdentifiers.IOptions) options: IOptions,
(ServiceIdentifiers.IArrayUtils) arrayUtils: IArrayUtils,
) {
super(randomGenerator, options);
this.arrayUtils = arrayUtils;
}
/**
* @returns {TNodeWithLexicalScopeStatements | undefined}
*/
public getLastElement (): TNodeWithLexicalScopeStatements | undefined {
return this.arrayUtils.getLastElement(this.getStorage());
}
/**
* @returns {TNodeWithLexicalScopeStatements | undefined}
*/
public getPenultimateElement (): TNodeWithLexicalScopeStatements | undefined {
const storageLength: number = this.getLength();
return this.get(storageLength - 2) ?? undefined;
}
/**
* @param {TNodeWithLexicalScopeStatements} nodeWithLexicalScopeStatements
*/
public push (nodeWithLexicalScopeStatements: TNodeWithLexicalScopeStatements): void {
const storageLength: number = this.getLength();
this.set(storageLength, nodeWithLexicalScopeStatements);
}
/**
* @returns {TNodeWithLexicalScopeStatements| undefined}
*/
public pop (): TNodeWithLexicalScopeStatements | undefined {
const storageLength: number = this.getLength();
return this.delete(storageLength - 1);
}
}