assertInteger()function

assertInteger(value: unknown, min?: number, max?: number, caller: AnyCaller = assertInteger): asserts value is number
ParamType
valueunknown
The value to assert. required
minnumber
Minimum allowed value, inclusive.
maxnumber
Maximum allowed value, inclusive.
callerAnyCaller
Function used to attribute a thrown error to the calling site. Defaults to assertInteger
Return
asserts value is number
Nothing; narrows value to number.
Throws
unknown
RequiredError if value is not an integer within range.

Assert that a value is an integer (optionally within specified min/max values).

Examples

assertInteger(5, 0, 10); // passes