Const
Casts a number to the PositiveSafeInt branded type.
number
PositiveSafeInt
Validates that the value is a positive safe integer and returns it with the PositiveSafeInt brand. Throws a TypeError otherwise.
TypeError
The value as a PositiveSafeInt
const branded = asPositiveSafeInt(128);assert.isTrue(branded === 128);assert.isTrue(PositiveSafeInt.is(branded)); Copy
const branded = asPositiveSafeInt(128);assert.isTrue(branded === 128);assert.isTrue(PositiveSafeInt.is(branded));
If the value is not a positive safe integer
Casts a
numberto thePositiveSafeIntbranded type.Validates that the value is a positive safe integer and returns it with the
PositiveSafeIntbrand. Throws aTypeErrorotherwise.