All files / src/custom-nodes/debug-protection-nodes/factory DebugProtectionCustomNodesFactory.ts

61.54% Statements 8/13
25% Branches 1/4
100% Functions 0/0
61.54% Lines 8/13
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 43      1x 1x 1x   1x 1x   1x           2619x 2619x                                                  
import { ICustomNode } from '../../../interfaces/custom-nodes/ICustomNode';
import { IStackTraceData } from '../../../interfaces/stack-trace-analyzer/IStackTraceData';
 
import { DebugProtectionFunctionCallNode } from '../DebugProtectionFunctionCallNode';
import { DebugProtectionFunctionIntervalNode } from '../DebugProtectionFunctionIntervalNode';
import { DebugProtectionFunctionNode } from '../DebugProtectionFunctionNode';
 
import { AbstractCustomNodesFactory } from '../../AbstractCustomNodesFactory';
import { Utils } from '../../../Utils';
 
export class DebugProtectionCustomNodesFactory extends AbstractCustomNodesFactory {
    /**
     * @param stackTraceData
     * @returns {Map<string, ICustomNode>}
     */
    public initializeCustomNodes (stackTraceData: IStackTraceData[]): Map <string, ICustomNode> | undefined {
        Eif (!this.options.debugProtection) {
            return;
        }
 
        const debugProtectionFunctionName: string = Utils.getRandomVariableName();
        const customNodes: Map <string, ICustomNode> = new Map <string, ICustomNode> ([
            [
                'debugProtectionFunctionNode',
                new DebugProtectionFunctionNode(debugProtectionFunctionName, this.options)
            ],
            [
                'debugProtectionFunctionCallNode',
                new DebugProtectionFunctionCallNode(debugProtectionFunctionName, this.options)
            ]
        ]);
 
        if (this.options.debugProtectionInterval) {
            customNodes.set(
                'debugProtectionFunctionIntervalNode',
                new DebugProtectionFunctionIntervalNode(debugProtectionFunctionName, this.options)
            );
        }
 
        return this.syncCustomNodesWithNodesFactory(customNodes);
    }
}