Const
Casts a number to a PositiveInt branded type.
This function validates that the input is a positive integer (>= 1) and returns it with the PositiveInt brand. This ensures type safety for operations that require strictly positive integer values.
The value as a PositiveInt branded type
const branded = asPositiveInt(7);assert(branded === 7);assert.ok(PositiveInt.is(branded)); Copy
const branded = asPositiveInt(7);assert(branded === 7);assert.ok(PositiveInt.is(branded));
If the value is not a positive integer
Casts a number to a PositiveInt branded type.
This function validates that the input is a positive integer (>= 1) and returns it with the PositiveInt brand. This ensures type safety for operations that require strictly positive integer values.