Adds two positive integers, returning a + b as a PositiveInt.
Divides two positive integers using floor division (⌊a / b⌋): the result
is a / b rounded toward negative infinity, as a PositiveInt.
Converts an arbitrary number into a PositiveInt, rounding to the
nearest integer and saturating the result into the range [MIN_VALUE, MAX_VALUE].
Unlike asPositiveInt, this is total: out-of-range inputs are clamped to
the nearest representable PositiveInt instead of throwing.
Type guard that checks if a value is a positive integer.
assert.isTrue(isPositiveInt(5));
assert.isFalse(isPositiveInt(0));
assert.isTrue(PositiveInt.is(10));
isPositiveInt for usage examples
Readonlymax: (...values: readonly WithSmallInt<PositiveInt>[]) => PositiveIntReturns the largest of the given positive integers.
Readonlymin: (...values: readonly WithSmallInt<PositiveInt>[]) => PositiveIntReturns the smallest of the given positive integers.
The smallest value representable as PositiveInt (the lower saturation
target of fromNumber).
Multiplies two positive integers, returning a * b as a PositiveInt.
Raises a to the power b, returning a ** b as a PositiveInt (floored
to an integer).
Generates a random PositiveInt within the given range.
The range is inclusive on both ends.
Subtracts two positive integers, returning a - b as a PositiveInt.
Namespace providing type-safe operations for the
PositiveIntbranded type.The
PositiveInttype represents a positive integer. Division (div) uses floor division.Unlike
SafeInt,PositiveIntallows values outside the safe integer range (±2^53 − 1), so very large magnitudes may lose precision in JavaScript'snumbertype.