# All files / src JavaScriptObfuscator.js

100% Statements 16/16
100% Branches 1/1
100% Functions 0/0
100% Lines 14/14

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

    8x
    8x
    8x

    6x

    8x
    8x

    8x

    1x

    1x
     "use strict";
    const esprima = require('esprima');
    const escodegen = require('escodegen');
    const JavaScriptObfuscatorCLI_1 = require("./cli/JavaScriptObfuscatorCLI");
    const Obfuscator_1 = require("./Obfuscator");
    const Options_1 = require("./Options");
    class JavaScriptObfuscator {
        static obfuscate(sourceCode, customOptions) {
            let astTree = esprima.parse(sourceCode), options = new Options_1.Options(customOptions), obfuscator = new Obfuscator_1.Obfuscator(options);
            astTree = obfuscator.obfuscateNode(astTree);
            return JavaScriptObfuscator.generateCode(astTree, options);
        }
        static runCLI(argv) {
            new JavaScriptObfuscatorCLI_1.JavaScriptObfuscatorCLI(argv).run();
        }
        static generateCode(astTree, options) {
            let escodegenParams = Object.assign({}, JavaScriptObfuscator.escodegenParams);
            escodegenParams.format = {
                compact: options.get('compact')
            };
            return escodegen.generate(astTree, escodegenParams);
        }
    }
    JavaScriptObfuscator.escodegenParams = {
        verbatim: 'x-verbatim-property'
    };
    exports.JavaScriptObfuscator = JavaScriptObfuscator;
    //# sourceMappingURL=JavaScriptObfuscator.js.map