# All files / src/custom-nodes/unicode-array-nodes UnicodeArrayCallsWrapper.js

95.65% Statements 22/23
66.67% Branches 2/3
100% Functions 1/1
95.45% Lines 21/22

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

    6x

    2x
    2x
    2x
    2x
    2x

    2x

    59x

    2x

    2x
    2x

    4x
    4x

    4x
    4x

    1x
     "use strict";
    const esprima = require('esprima');
    const AppendState_1 = require("../../enums/AppendState");
    const Node_1 = require('../Node');
    const NodeUtils_1 = require("../../NodeUtils");
    const Utils_1 = require("../../Utils");
    class UnicodeArrayCallsWrapper extends Node_1.Node {
        constructor(unicodeArrayCallsWrapperName, unicodeArrayName, unicodeArray, options) {
            super(options);
            this.appendState = AppendState_1.AppendState.AfterObfuscation;
            this.unicodeArrayCallsWrapperName = unicodeArrayCallsWrapperName;
            this.unicodeArrayName = unicodeArrayName;
            this.unicodeArray = unicodeArray;
            this.node = this.getNodeStructure();
        }
        appendNode(blockScopeNode) {
            NodeUtils_1.NodeUtils.insertNodeAtIndex(blockScopeNode.body, this.getNode(), 1);
        }
        getNodeIdentifier() {
            return this.unicodeArrayCallsWrapperName;
        }
        ;
        getNode() {
            if (!this.unicodeArray.length) I{
                return;
            }
            this.updateNode();
            return super.getNode();
        }
        getNodeStructure() {
            let keyName = Utils_1.Utils.getRandomVariableName(), node;
            node = esprima.parse(`
                var ${this.unicodeArrayCallsWrapperName} = function (${keyName}) {
                    return ${this.unicodeArrayName}[parseInt(${keyName}, 0x010)];
                };
            `);
            NodeUtils_1.NodeUtils.addXVerbatimPropertyToLiterals(node);
            return NodeUtils_1.NodeUtils.getBlockStatementNodeByIndex(node);
        }
    }
    exports.UnicodeArrayCallsWrapper = UnicodeArrayCallsWrapper;
    //# sourceMappingURL=UnicodeArrayCallsWrapper.js.map