Const
Casts a number to a SafeInt branded type.
This function validates that the input is a safe integer (within ±(2^53 - 1)) and returns it with the SafeInt brand. This ensures type safety for operations that require precise integer arithmetic.
The value as a SafeInt branded type
const branded = asSafeInt(123);assert(branded === 123);assert.ok(SafeInt.is(branded)); Copy
const branded = asSafeInt(123);assert(branded === 123);assert.ok(SafeInt.is(branded));
If the value is not a safe integer
Casts a number to a SafeInt branded type.
This function validates that the input is a safe integer (within ±(2^53 - 1)) and returns it with the SafeInt brand. This ensures type safety for operations that require precise integer arithmetic.