Const
Casts a number to the PositiveInt branded type.
number
PositiveInt
Validates that the value is a positive integer and returns it with the PositiveInt brand. Throws a TypeError otherwise.
TypeError
The value as a PositiveInt
const branded = asPositiveInt(7);assert.isTrue(branded === 7);assert.isTrue(PositiveInt.is(branded)); Copy
const branded = asPositiveInt(7);assert.isTrue(branded === 7);assert.isTrue(PositiveInt.is(branded));
If the value is not a positive integer
Casts a
numberto thePositiveIntbranded type.Validates that the value is a positive integer and returns it with the
PositiveIntbrand. Throws aTypeErrorotherwise.