Code coverage report for src/node-transformers/node-control-flow-transformers/control-flow-replacers/AbstractControlFlowReplacer.ts

# All files / src/node-transformers/node-control-flow-transformers/control-flow-replacers AbstractControlFlowReplacer.ts

62.5% Statements 5/8
100% Branches 0/0
0% Functions 0/1
62.5% Lines 5/8

    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
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    611x
    1x

    1x

    1x
    1x

     import { injectable, inject } from 'inversify';
    import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers';

    import * as ESTree from 'estree';

    import { IControlFlowReplacer } from '../../../interfaces/node-transformers/IControlFlowReplacer';
    import { ICustomNode } from '../../../interfaces/custom-nodes/ICustomNode';
    import { IOptions } from '../../../interfaces/options/IOptions';
    import { IStorage } from '../../../interfaces/storages/IStorage';

    import { Utils } from '../../../Utils';

    @injectable()
    export abstract class AbstractControlFlowReplacer implements IControlFlowReplacer {
        /**
         * @type IStorage<ICustomNode>
         */
        protected readonly customNodesStorage: IStorage<ICustomNode>;

        /**
         * @type {IOptions}
         */
        protected readonly options : IOptions;

        /**
         * @param customNodesStorage
         * @param options
         */
        constructor (
            @inject(ServiceIdentifiers['IStorage<ICustomNode>']) customNodesStorage: IStorage<ICustomNode>,
            @inject(ServiceIdentifiers.IOptions) options: IOptions
        ) {
            this.customNodesStorage = customNodesStorage;
            this.options = options;
        }

        /**
         * @returns {string}
         */
        protected static getStorageKey (): string {
            return Utils.getRandomGenerator().string({
                length: 3,
                pool: Utils.randomGeneratorPool
            });
        }

        /**
         * @param node
         * @param parentNode
         * @param controlFlowStorage
         * @param controlFlowStorageCustomNodeName
         * @returns {ICustomNode | undefined}
         */
        public abstract replace (
            node: ESTree.Node,
            parentNode: ESTree.Node,
            controlFlowStorage: IStorage <ICustomNode>,
            controlFlowStorageCustomNodeName: string
        ): ICustomNode | undefined;
    }