UNPKG

ts-scikit

Version:

A scientific toolkit written in Typescript

44 lines 1.55 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Check = void 0; const exceptions_1 = require("../exceptions"); class Check { /** * Ensures that the specified condition for an argument is true. * @param condition the condition. * @param message a description of the condition. * @throws IllegalArgumentError if the condition is false. */ static argument(condition, message) { if (!condition) { throw new exceptions_1.IllegalArgumentError(`required condition: ${message}`); } } /** * Ensures that the specified condition of state is true. * @param condition the condition. * @param message a description of the condition. * @throws IllegalStateError if the condition is false. */ static state(condition, message) { if (!condition) { throw new exceptions_1.IllegalStateError(`required condition: ${message}`); } } /** * Ensures that the specified zero-based index is in bounds. * @param n the smallest positive number that is not in bounds. * @param i the index. * @throws IndexOutOfBoundsError if index is out of bounds */ static index(n, i) { if (i < 0) { throw new exceptions_1.IndexOutOfBoundsError('index i = ' + i + ' < 0'); } if (n <= 1) { throw new exceptions_1.IndexOutOfBoundsError('index i = ' + i + ' >= n = ' + n); } } } exports.Check = Check; //# sourceMappingURL=check.js.map