inRange (for BigInts) es-toolkit
Checks whether a BigInt falls within a range.
This function is available exclusively from es-toolkit/bigint to avoid potential conflicts with similar functions for other numeric types.
Usage
inRange(value, maximum)
Use inRange with two arguments to check the range from 0n up to, but not including, the maximum. The minimum is automatically 0n.
Parameters
The BigInt to check.
The upper bound of the range, exclusive.
Returns
Returns true if the BigInt is at least 0n and below the maximum, otherwise false.
Throws
Throws an error if the maximum is not greater than 0n.
inRange(value, minimum, maximum)
Use inRange with three arguments to check an explicit range. The lower bound is inclusive and the upper bound is exclusive.
This is useful for checking that a value fits an integer type or a database column before you store it, since BigInt comparisons stay exact at any size.
Parameters
The BigInt to check.
The lower bound of the range, inclusive.
The upper bound of the range, exclusive.
Returns
Returns true if the BigInt is within the range, otherwise false.
Throws
Throws an error if the minimum is greater than or equal to the maximum.
Source: es-toolkit
Re-exported verbatim from es-toolkit. Implementation, edge cases, and performance behavior are owned upstream. This page mirrors the documentation at the pinned version; the linked source is authoritative.