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

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

31.25% Statements 5/16
16.67% Branches 1/6
0% Functions 0/2
33.33% Lines 5/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
    1x
    1x
    1x
    1x

    1x
     "use strict";
    const estraverse = require('estraverse');
    const NodeObfuscator_1 = require('./NodeObfuscator');
    const Nodes_1 = require("../Nodes");
    const Utils_1 = require("../Utils");
    class MethodDefinitionObfuscator extends NodeObfuscator_1.NodeObfuscator {
        constructor(...args) {
            super(...args);
            this.ignoredNames = ['constructor'];
        }
        obfuscateNode(methodDefinitionNode, parentNode) {
            this.replaceMethodName(methodDefinitionNode);
        }
        replaceMethodName(methodDefinitionNode) {
            estraverse.replace(methodDefinitionNode.key, {
                leave: (node) => {
                    if (Nodes_1.Nodes.isIdentifierNode(node) &&
                        !Utils_1.Utils.arrayContains(this.ignoredNames, node.name) &&
                        methodDefinitionNode.computed === false) {
                        methodDefinitionNode.computed = true;
                        node.name = this.replaceLiteralValueWithUnicodeValue(node.name);
                        return;
                    }
                    return estraverse.VisitorOption.Skip;
                }
            });
        }
    }
    exports.MethodDefinitionObfuscator = MethodDefinitionObfuscator;
    //# sourceMappingURL=MethodDefinitionObfuscator.js.map