Code coverage report for src/JavaScriptObfuscator.ts

# All files / src JavaScriptObfuscator.ts

100% Statements 15/15
100% Branches 4/4
100% Functions 0/0
100% Lines 15/15

    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
    441x

    1x

    1x
    1x
    1x

    1x

    6263x
    6263x
    6263x

    6263x

    6263x

    6263x

    6263x

    6263x

    10x

     import 'reflect-metadata';

    import { ServiceIdentifiers } from './container/ServiceIdentifiers';

    import { TInputOptions } from './types/options/TInputOptions';

    import { IInversifyContainerFacade } from './interfaces/container/IInversifyContainerFacade';
    import { IJavaScriptObfuscator } from './interfaces/IJavaScriptObfsucator';
    import { IObfuscationResult } from './interfaces/IObfuscationResult';
    import { IOptions } from './interfaces/options/IOptions';

    import { InversifyContainerFacade } from './container/InversifyContainerFacade';
    import { JavaScriptObfuscatorCLI } from './cli/JavaScriptObfuscatorCLI';
    import { RandomGeneratorUtils } from './utils/RandomGeneratorUtils';

    export class JavaScriptObfuscator {
        /**
         * @param sourceCode
         * @param inputOptions
         * @returns {string}
         */
        public static obfuscate (sourceCode: string, inputOptions: TInputOptions = {}): IObfuscationResult {
            const inversifyContainerFacade: IInversifyContainerFacade = new InversifyContainerFacade(inputOptions);
            const options: IOptions = inversifyContainerFacade.get<IOptions>(ServiceIdentifiers.IOptions);

            RandomGeneratorUtils.initializeRandomGenerator(options.seed);

            const javaScriptObfuscator: IJavaScriptObfuscator = inversifyContainerFacade
                .get<IJavaScriptObfuscator>(ServiceIdentifiers.IJavaScriptObfuscator);
            const obfuscationResult: IObfuscationResult = javaScriptObfuscator.obfuscate(sourceCode);

            RandomGeneratorUtils.clearRandomGenerator();

            return obfuscationResult;
        }

        /**
         * @param argv
         */
        public static runCLI (argv: string[]): void {
            new JavaScriptObfuscatorCLI(argv).run();
        }
    }