UNPKG

typescript-util

Version:

JS/TS 的简单工具

41 lines 1.19 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Assert = void 0; const AssertException_1 = require("../exception/AssertException"); /** * Assert * @author LL * @date 2022-01-22 上午 12:50 **/ class Assert { /** * 断言 true * @param {boolean} status * @param {string} msg */ static isTrue(status, msg) { // noinspection SuspiciousTypeOfGuard if (typeof status !== 'boolean') { throw new TypeError('期望 boolean 类型, 实际获得 ' + status); } if (!status) { throw new AssertException_1.AssertException(msg ?? '断言错误: 期望 true'); } } /** * 断言 false * @param {boolean} status * @param {string} msg */ static isFalse(status, msg) { // noinspection SuspiciousTypeOfGuard if (typeof status !== 'boolean') { throw new TypeError('期望 boolean 类型, 实际获得 ' + status); } if (status) { throw new AssertException_1.AssertException(msg ?? '断言错误: 期望 false'); } } } exports.Assert = Assert; //# sourceMappingURL=Assert.js.map