forked from javascript-obfuscator/javascript-obfuscator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOptionsNormalizer.ts
More file actions
48 lines (42 loc) · 1.84 KB
/
OptionsNormalizer.ts
File metadata and controls
48 lines (42 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { TOptionsNormalizerRule } from '../types/options/TOptionsNormalizerRule';
import { IOptions } from '../interfaces/options/IOptions';
import { ControlFlowFlatteningThresholdRule } from './normalizer-rules/ControlFlowFlatteningThresholdRule';
import { DeadCodeInjectionRule } from './normalizer-rules/DeadCodeInjectionRule';
import { DeadCodeInjectionThresholdRule } from './normalizer-rules/DeadCodeInjectionThresholdRule';
import { DomainLockRule } from './normalizer-rules/DomainLockRule';
import { SelfDefendingRule } from './normalizer-rules/SelfDefendingRule';
import { SourceMapBaseUrlRule } from './normalizer-rules/SourceMapBaseUrlRule';
import { SourceMapFileNameRule } from './normalizer-rules/SourceMapFileNameRule';
import { StringArrayRule } from './normalizer-rules/StringArrayRule';
import { StringArrayEncodingRule } from './normalizer-rules/StringArrayEncodingRule';
import { StringArrayThresholdRule } from './normalizer-rules/StringArrayThresholdRule';
export class OptionsNormalizer {
/**
* @type {TOptionsNormalizerRule[]}
*/
private static readonly normalizerRules: TOptionsNormalizerRule[] = [
ControlFlowFlatteningThresholdRule,
DeadCodeInjectionRule,
DeadCodeInjectionThresholdRule,
DomainLockRule,
SelfDefendingRule,
SourceMapBaseUrlRule,
SourceMapFileNameRule,
StringArrayRule,
StringArrayEncodingRule,
StringArrayThresholdRule,
];
/**
* @param {IOptions} options
* @returns {IOptions}
*/
public static normalizeOptions (options: IOptions): IOptions {
let normalizedOptions: IOptions = {
...options
};
for (const normalizerRule of OptionsNormalizer.normalizerRules) {
normalizedOptions = normalizerRule(normalizedOptions);
}
return normalizedOptions;
}
}