All files / lib/optimization conditionalExp.js

100% Statements 11/11
100% Branches 4/4
100% Functions 1/1
100% Lines 11/11

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  3x 3x       3x 3x   9x   9x 4x   5x 2x   9x   3x  
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.handleConditionalExp = void 0;
/*
 * @copyright Microsoft Corporation. All rights reserved.
 */
const ts_morph_1 = require("ts-morph");
const utils_1 = require("../utils");
function handleConditionalExp(exp) {
    const cond = exp.getCondition();
    let newWork;
    if (cond.getKind() === ts_morph_1.SyntaxKind.TrueKeyword) {
        newWork = exp.replaceWithText(exp.getWhenTrue().getText());
    }
    else if (cond.getKind() === ts_morph_1.SyntaxKind.FalseKeyword) {
        newWork = exp.replaceWithText(exp.getWhenFalse().getText());
    }
    return (0, utils_1.tryUnwrapParenthese)(newWork);
}
exports.handleConditionalExp = handleConditionalExp;