mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
Renamed TObject -> TDictionary (#616)
* Renamed TObject -> TDictionary * Added key features to the README.md
This commit is contained in:
@@ -4,7 +4,7 @@ import { ServiceIdentifiers } from './container/ServiceIdentifiers';
|
||||
|
||||
import { TInputOptions } from './types/options/TInputOptions';
|
||||
import { TObfuscationResultsObject } from './types/TObfuscationResultsObject';
|
||||
import { TObject } from './types/TObject';
|
||||
import { TDictionary } from './types/TDictionary';
|
||||
|
||||
import { IInversifyContainerFacade } from './interfaces/container/IInversifyContainerFacade';
|
||||
import { IJavaScriptObfuscator } from './interfaces/IJavaScriptObfsucator';
|
||||
@@ -43,7 +43,7 @@ class JavaScriptObfuscatorFacade {
|
||||
* @param {TInputOptions} inputOptions
|
||||
* @returns {TObfuscationResultsObject<TSourceCodesObject>}
|
||||
*/
|
||||
public static obfuscateMultiple <TSourceCodesObject extends TObject<string>> (
|
||||
public static obfuscateMultiple <TSourceCodesObject extends TDictionary<string>> (
|
||||
sourceCodesObject: TSourceCodesObject,
|
||||
inputOptions: TInputOptions = {}
|
||||
): TObfuscationResultsObject<TSourceCodesObject> {
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { TObject } from '../../types/TObject';
|
||||
import { TDictionary } from '../../types/TDictionary';
|
||||
|
||||
export class CLIUtils {
|
||||
/**
|
||||
* @param {string} configPath
|
||||
* @returns {TObject}
|
||||
* @returns {TDictionary}
|
||||
*/
|
||||
public static getUserConfig (configPath: string): TObject {
|
||||
let config: TObject;
|
||||
public static getUserConfig (configPath: string): TDictionary {
|
||||
let config: TDictionary;
|
||||
|
||||
try {
|
||||
config = require(configPath);
|
||||
|
||||
@@ -3,7 +3,7 @@ import { inject, injectable } from 'inversify';
|
||||
import { ServiceIdentifiers } from '../container/ServiceIdentifiers';
|
||||
|
||||
import { TCodeTransformerFactory } from '../types/container/code-transformers/TCodeTransformerFactory';
|
||||
import { TObject } from '../types/TObject';
|
||||
import { TDictionary } from '../types/TDictionary';
|
||||
|
||||
import { ICodeTransformer } from '../interfaces/code-transformers/ICodeTransformer';
|
||||
import { ICodeTransformersRunner } from '../interfaces/code-transformers/ICodeTransformersRunner';
|
||||
@@ -59,7 +59,7 @@ export class CodeTransformersRunner implements ICodeTransformersRunner {
|
||||
return code;
|
||||
}
|
||||
|
||||
const normalizedCodeTransformers: TObject<ICodeTransformer> =
|
||||
const normalizedCodeTransformers: TDictionary<ICodeTransformer> =
|
||||
this.buildNormalizedCodeTransformers(codeTransformerNames, codeTransformationStage);
|
||||
const codeTransformerNamesGroups: CodeTransformer[][] =
|
||||
this.codeTransformerNamesGroupsBuilder.build(normalizedCodeTransformers);
|
||||
@@ -78,15 +78,15 @@ export class CodeTransformersRunner implements ICodeTransformersRunner {
|
||||
/**
|
||||
* @param {NodeTransformer[]} codeTransformerNames
|
||||
* @param {NodeTransformationStage} codeTransformationStage
|
||||
* @returns {TObject<INodeTransformer>}
|
||||
* @returns {TDictionary<INodeTransformer>}
|
||||
*/
|
||||
private buildNormalizedCodeTransformers (
|
||||
codeTransformerNames: CodeTransformer[],
|
||||
codeTransformationStage: CodeTransformationStage
|
||||
): TObject<ICodeTransformer> {
|
||||
): TDictionary<ICodeTransformer> {
|
||||
return codeTransformerNames
|
||||
.reduce<TObject<ICodeTransformer>>(
|
||||
(acc: TObject<ICodeTransformer>, codeTransformerName: CodeTransformer) => {
|
||||
.reduce<TDictionary<ICodeTransformer>>(
|
||||
(acc: TDictionary<ICodeTransformer>, codeTransformerName: CodeTransformer) => {
|
||||
const codeTransformer: ICodeTransformer = this.codeTransformerFactory(codeTransformerName);
|
||||
|
||||
return {
|
||||
|
||||
@@ -5,7 +5,7 @@ import * as estraverse from 'estraverse';
|
||||
import * as ESTree from 'estree';
|
||||
import format from 'string-template';
|
||||
|
||||
import { TObject } from '../types/TObject';
|
||||
import { TDictionary } from '../types/TDictionary';
|
||||
import { TStatement } from '../types/node/TStatement';
|
||||
|
||||
import { ICustomCodeHelperFormatter } from '../interfaces/custom-code-helpers/ICustomCodeHelperFormatter';
|
||||
@@ -32,7 +32,7 @@ export class CustomCodeHelperFormatter implements ICustomCodeHelperFormatter {
|
||||
* @param {TMapping} mapping
|
||||
* @returns {string}
|
||||
*/
|
||||
public formatTemplate <TMapping extends TObject> (
|
||||
public formatTemplate <TMapping extends TDictionary> (
|
||||
template: string,
|
||||
mapping: TMapping
|
||||
): string {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { TObject } from '../../types/TObject';
|
||||
import { TDictionary } from '../../types/TDictionary';
|
||||
import { TStatement } from '../../types/node/TStatement';
|
||||
|
||||
export interface ICustomCodeHelperFormatter {
|
||||
@@ -7,7 +7,7 @@ export interface ICustomCodeHelperFormatter {
|
||||
* @param {TMapping} mapping
|
||||
* @returns {string}
|
||||
*/
|
||||
formatTemplate <TMapping extends TObject> (
|
||||
formatTemplate <TMapping extends TDictionary> (
|
||||
template: string,
|
||||
mapping: TMapping
|
||||
): string;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { TObject } from '../../types/TObject';
|
||||
import { TDictionary } from '../../types/TDictionary';
|
||||
|
||||
export interface ITransformerNamesGroupsBuilder <
|
||||
TTransformerName extends string,
|
||||
TTransformer
|
||||
> {
|
||||
/**
|
||||
* @param {TObject<TTransformer>} normalizedTransformers
|
||||
* @param {TDictionary<TTransformer>} normalizedTransformers
|
||||
* @returns {TTransformerName[][]}
|
||||
*/
|
||||
build (normalizedTransformers: TObject<TTransformer>): TTransformerName[][];
|
||||
build (normalizedTransformers: TDictionary<TTransformer>): TTransformerName[][];
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import * as estraverse from 'estraverse';
|
||||
import * as ESTree from 'estree';
|
||||
|
||||
import { TNodeTransformerFactory } from '../types/container/node-transformers/TNodeTransformerFactory';
|
||||
import { TObject } from '../types/TObject';
|
||||
import { TDictionary } from '../types/TDictionary';
|
||||
import { TVisitorDirection } from '../types/node-transformers/TVisitorDirection';
|
||||
import { TVisitorFunction } from '../types/node-transformers/TVisitorFunction';
|
||||
import { TVisitorResult } from '../types/node-transformers/TVisitorResult';
|
||||
@@ -70,7 +70,7 @@ export class NodeTransformersRunner implements INodeTransformersRunner {
|
||||
return astTree;
|
||||
}
|
||||
|
||||
const normalizedNodeTransformers: TObject<INodeTransformer> =
|
||||
const normalizedNodeTransformers: TDictionary<INodeTransformer> =
|
||||
this.buildNormalizedNodeTransformers(nodeTransformerNames, nodeTransformationStage);
|
||||
const nodeTransformerNamesGroups: NodeTransformer[][] =
|
||||
this.nodeTransformerNamesGroupsBuilder.build(normalizedNodeTransformers);
|
||||
@@ -112,15 +112,15 @@ export class NodeTransformersRunner implements INodeTransformersRunner {
|
||||
/**
|
||||
* @param {NodeTransformer[]} nodeTransformerNames
|
||||
* @param {NodeTransformationStage} nodeTransformationStage
|
||||
* @returns {TObject<INodeTransformer>}
|
||||
* @returns {TDictionary<INodeTransformer>}
|
||||
*/
|
||||
private buildNormalizedNodeTransformers (
|
||||
nodeTransformerNames: NodeTransformer[],
|
||||
nodeTransformationStage: NodeTransformationStage
|
||||
): TObject<INodeTransformer> {
|
||||
): TDictionary<INodeTransformer> {
|
||||
return nodeTransformerNames
|
||||
.reduce<TObject<INodeTransformer>>(
|
||||
(acc: TObject<INodeTransformer>, nodeTransformerName: NodeTransformer) => {
|
||||
.reduce<TDictionary<INodeTransformer>>(
|
||||
(acc: TDictionary<INodeTransformer>, nodeTransformerName: NodeTransformer) => {
|
||||
const nodeTransformer: INodeTransformer = this.nodeTransformerFactory(nodeTransformerName);
|
||||
|
||||
if (!nodeTransformer.getVisitor(nodeTransformationStage)) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { ValidationError } from 'class-validator';
|
||||
|
||||
import { TObject } from '../types/TObject';
|
||||
import { TDictionary } from '../types/TDictionary';
|
||||
|
||||
export class ValidationErrorsFormatter {
|
||||
/**
|
||||
@@ -24,7 +24,7 @@ export class ValidationErrorsFormatter {
|
||||
* @returns {string}
|
||||
*/
|
||||
private static formatWithNestedConstraints (error: ValidationError): string {
|
||||
const constraints: TObject<string> | undefined = error.constraints;
|
||||
const constraints: TDictionary<string> | undefined = error.constraints;
|
||||
|
||||
if (!constraints) {
|
||||
return `\`${error.property}\` error\n`;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
/* eslint-disable @typescript-eslint/consistent-type-definitions */
|
||||
|
||||
export type TObject <T = unknown> = {[key: string]: T};
|
||||
export type TDictionary <T = unknown> = {[key: string]: T};
|
||||
@@ -1,5 +1,5 @@
|
||||
import { TObject } from '../TObject';
|
||||
import { TDictionary } from '../TDictionary';
|
||||
|
||||
import { ICLIOptions } from '../../interfaces/options/ICLIOptions';
|
||||
|
||||
export type TInputCLIOptions = Partial<Pick<ICLIOptions, keyof ICLIOptions>> & TObject;
|
||||
export type TInputCLIOptions = Partial<Pick<ICLIOptions, keyof ICLIOptions>> & TDictionary;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { TObject } from '../TObject';
|
||||
import { TDictionary } from '../TDictionary';
|
||||
|
||||
import { IOptions } from '../../interfaces/options/IOptions';
|
||||
|
||||
export type TInputOptions = Partial<Pick<IOptions, keyof IOptions>> & TObject;
|
||||
export type TInputOptions = Partial<Pick<IOptions, keyof IOptions>> & TDictionary;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { inject, injectable } from 'inversify';
|
||||
import { ServiceIdentifiers } from '../container/ServiceIdentifiers';
|
||||
|
||||
import { TObject } from '../types/TObject';
|
||||
import { TDictionary } from '../types/TDictionary';
|
||||
import { TTransformersRelationEdge } from '../types/utils/TTransformersRelationEdge';
|
||||
|
||||
import { ILevelledTopologicalSorter } from '../interfaces/utils/ILevelledTopologicalSorter';
|
||||
@@ -48,10 +48,10 @@ export abstract class AbstractTransformerNamesGroupsBuilder <
|
||||
* ]
|
||||
* ]
|
||||
*
|
||||
* @param {TObject<TTransformer>} normalizedTransformers
|
||||
* @param {TDictionary<TTransformer>} normalizedTransformers
|
||||
* @returns {TTransformerName[][]}
|
||||
*/
|
||||
public build (normalizedTransformers: TObject<TTransformer>): TTransformerName[][] {
|
||||
public build (normalizedTransformers: TDictionary<TTransformer>): TTransformerName[][] {
|
||||
const transformerNames: TTransformerName[] = <TTransformerName[]>Object.keys(normalizedTransformers);
|
||||
const relationEdges: TTransformersRelationEdge<TTransformerName>[] = this.buildTransformersRelationEdges(
|
||||
transformerNames,
|
||||
@@ -67,12 +67,12 @@ export abstract class AbstractTransformerNamesGroupsBuilder <
|
||||
|
||||
/**
|
||||
* @param {TTransformerName[]} transformerNames
|
||||
* @param {TObject<TTransformer>} normalizedTransformers
|
||||
* @param {TDictionary<TTransformer>} normalizedTransformers
|
||||
* @returns {TTransformersRelationEdge<TTransformerName>[]}
|
||||
*/
|
||||
private buildTransformersRelationEdges (
|
||||
transformerNames: TTransformerName[],
|
||||
normalizedTransformers: TObject<TTransformer>
|
||||
normalizedTransformers: TDictionary<TTransformer>
|
||||
): TTransformersRelationEdge<TTransformerName>[] {
|
||||
const relationEdges: TTransformersRelationEdge<TTransformerName>[] = [];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user