Code coverage report for src/JavaScriptObfuscator.ts

# All files / src JavaScriptObfuscator.ts

91.67% Statements 11/12
83.33% Branches 5/6
100% Functions 0/0
91.67% Lines 11/12

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

    1x

    1x
    1x
    1x

    1x

    2620x
    2620x
    2620x

    2620x

    10x

     import 'reflect-metadata';

    Iif (!(<any>global)._babelPolyfill) {
        require('babel-polyfill');
    }

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

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

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

            return javaScriptObfuscator.obfuscate(sourceCode);
        }

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