All files / src Options.ts

100% Statements 19/19
100% Branches 0/0
100% Functions 1/1
100% Lines 19/19
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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 1041x             1x   1x   1x       1x           1x           1x           1x           1x                     1x           1x           1x           1x           1x           1x               1x           1x 21x   21x            
import { IsBoolean, IsIn, IsInt, Min, Max, validateSync } from 'class-validator';
 
import { IObfuscatorOptions } from "./interfaces/IObfuscatorOptions";
import { IOptions } from "./interfaces/IOptions";
 
import { TSourceMapMode } from "./types/TSourceMapMode";
 
import { DEFAULT_PRESET } from "./preset-options/DefaultPreset";
 
import { OptionsNormalizer } from "./OptionsNormalizer";
 
export class Options implements IOptions {
    /**
     * @type {boolean}
     */
    @IsBoolean()
    public readonly compact: boolean;
 
    /**
     * @type {boolean}
     */
    @IsBoolean()
    public readonly debugProtection: boolean;
 
    /**
     * @type {boolean}
     */
    @IsBoolean()
    public readonly debugProtectionInterval: boolean;
 
    /**
     * @type {boolean}
     */
    @IsBoolean()
    public readonly disableConsoleOutput: boolean;
 
    /**
     * @type {boolean}
     */
    @IsBoolean()
    public readonly encodeUnicodeLiterals: boolean;
 
    /**
     * @type {string[]}
     */
    public readonly reservedNames: string[];
 
    /**
     * @type {boolean}
     */
    @IsBoolean()
    public readonly rotateUnicodeArray: boolean;
 
    /**
     * @type {boolean}
     */
    @IsBoolean()
    public readonly selfDefending: boolean;
 
    /**
     * @type {boolean}
     */
    @IsBoolean()
    public readonly sourceMap: boolean;
 
    /**
     * @type {TSourceMapMode}
     */
    @IsIn(['inline', 'separate'])
    public readonly sourceMapMode: TSourceMapMode;
 
    /**
     * @type {boolean}
     */
    @IsBoolean()
    public readonly unicodeArray: boolean;
 
    /**
     * @type {number}
     */
    @IsInt()
    @Min(0)
    @Max(1)
    public readonly unicodeArrayThreshold: number;
 
    /**
     * @type {boolean}
     */
    @IsBoolean()
    public readonly wrapUnicodeArrayCalls: boolean;
 
    /**
     * @param obfuscatorOptions
     */
    constructor (obfuscatorOptions: IObfuscatorOptions) {
        validateSync(this);
 
        Object.assign(
            this,
            OptionsNormalizer.normalizeOptions(Object.assign({}, DEFAULT_PRESET, obfuscatorOptions))
        );
    }
}