Code coverage report for src/node-obfuscators/FunctionObfuscator.js

# All files / src/node-obfuscators FunctionObfuscator.js

100% Statements 18/18
100% Branches 1/1
100% Functions 5/5
100% Lines 17/17

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

    24x

    6x

    6x
    6x

    6x
    6x

    2x
    2x

    6x
    6x

    297x

    6x

    2x

    6x

    1x
     "use strict";
    const estraverse = require('estraverse');
    const NodeObfuscator_1 = require('./NodeObfuscator');
    class FunctionObfuscator extends NodeObfuscator_1.NodeObfuscator {
        constructor(...args) {
            super(...args);
            this.functionParams = new Map();
        }
        obfuscateNode(functionNode) {
            this.storeFunctionParams(functionNode);
            this.replaceFunctionParams(functionNode);
        }
        storeFunctionParams(functionNode) {
            functionNode.params
                .forEach((paramsNode) => {
                estraverse.traverse(paramsNode, {
                    leave: (node) => this.storeIdentifiersNames(node, this.functionParams)
                });
            });
        }
        replaceFunctionParams(functionNode) {
            let replaceVisitor = {
                leave: (node, parentNode) => {
                    this.replaceIdentifiersWithRandomNames(node, parentNode, this.functionParams);
                }
            };
            functionNode.params
                .forEach((paramsNode) => {
                estraverse.replace(paramsNode, replaceVisitor);
            });
            estraverse.replace(functionNode.body, replaceVisitor);
        }
    }
    exports.FunctionObfuscator = FunctionObfuscator;
    //# sourceMappingURL=FunctionObfuscator.js.map