This repository has been archived on 2022-03-12. You can view files and clone it, but cannot push or open issues or pull requests.
2021-04-02 02:24:13 +03:00

22 lines
771 B
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("./utils");
function ifElse(condition, ifTrueFragment, elseFragment) {
return new IfElse(condition, ifTrueFragment, elseFragment);
}
exports.ifElse = ifElse;
class IfElse {
constructor(condition, ifTrueFragment, elseFragment) {
this.condition = condition;
this.ifTrueFragment = ifTrueFragment;
this.elseFragment = elseFragment;
}
build() {
const value = Boolean(typeof this.condition === 'function' ? this.condition() : this.condition);
return utils_1.buildChildren([
value ? this.ifTrueFragment : this.elseFragment || '',
]);
}
}
exports.IfElse = IfElse;
//# sourceMappingURL=IfElse.js.map