Readonlyadd: (Adds two positive integers, returning a + b as a PositiveInt.
Readonlydiv: (Divides two positive integers using floor division (⌊a / b⌋): the result
is a / b rounded toward negative infinity, as a PositiveInt.
ReadonlyfromNumber: (x: number) => PositiveIntConverts 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.
Readonlyis: (a: number) => a is PositiveIntType 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, 40>[]) => PositiveIntReturns the largest of the given positive integers.
Readonlymin: (...values: readonly WithSmallInt<PositiveInt, 40>[]) => PositiveIntReturns the smallest of the given positive integers.
ReadonlyMIN_VALUE: 1The smallest value representable as PositiveInt (the lower saturation
target of fromNumber).
Readonlymul: (Multiplies two positive integers, returning a * b as a PositiveInt.
Readonlypow: (Raises a to the power b, returning a ** b as a PositiveInt (floored
to an integer).
Readonlyrandom: (Generates a random PositiveInt within the given range.
The range is inclusive on both ends.
Readonlysub: (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.