predictype
Version:
PredicType is a library of pre-built and tested predicates for TypeScript, covering various data types and operations.
30 lines (29 loc) • 1.13 kB
TypeScript
import { BigIntRangeOper } from '../../enums/bigints.js';
/**
* Checks if a bigint value falls within or outside a specified range using the given operation.
*
* @param source The source bigint value.
* @param oper The range operation to perform (e.g. 'between', 'not_between').
* @param min The minimum value of the range (inclusive).
* @param max The maximum value of the range (inclusive).
* @returns True if the range check is valid according to the operator, otherwise false.
*
* @throws {Error} If the operation is not recognized.
*
* @example
* const value1 = BigInt(5);
* const value2 = BigInt(15);
* const min = BigInt(1);
* const max = BigInt(10);
*
* bigintRange(value1, 'between', min, max); // true
* bigintRange(value2, 'not_between', min, max); // true
*
* @remarks
* Supported Operators:
* - **BETWEEN**: min <= value <= max
* - **NOT_BETWEEN**: value < min or value > max
* - **STRICT_BETWEEN**: min < value < max
* - **STRICT_NOT_BETWEEN**: value <= min or value >= max
*/
export declare function bigintRange(source: bigint, oper: BigIntRangeOper, min: bigint, max: bigint): boolean;