All files / dist SyntaxKindDelegator.js

81.25% Statements 13/16
62.5% Branches 5/8
100% Functions 1/1
81.25% Lines 13/16

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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  2x 2x 2x               2x 44x   44x 44x     44x   44x 44x 9x   35x   2x  
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.bySyntax = void 0;
const SyntaxKindMap_1 = require("./SyntaxKindMap");
/**
 * Uses a syntax kind to delegate actions to allow for automatic type based on syntax kind.
 * @param node
 * @param skMap
 * @param defaultFN
 * @returns
 */
const bySyntax = (node, skMap, defaultFN) => {
    Iif (!node)
        return defaultFN(node);
    const k = node.getKind();
    Iif (!(k in SyntaxKindMap_1.SyntaxKindDelegator)) {
        return defaultFN(node);
    }
    Iif (!SyntaxKindMap_1.SyntaxKindDelegator[k](node))
        return defaultFN(node);
    const entry = skMap[k];
    if (!entry)
        return defaultFN(node);
    //@ts-ignore
    return entry(node, defaultFN);
};
exports.bySyntax = bySyntax;