Package Exports
- safe-integer-ts
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (safe-integer-ts) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
SafeInteger for TypeScript
Provides SafeInteger type, a newtype wrapper of number as safe-integer or 53-bit precise integer.
See the implementations for more details.
Example
import { SafeInteger, asSafeInteger, isSafeInteger, toSafeInteger } from "safe-integer-ts"
const unknownValue: unknown = JSON.parse("42")
// As argument.
const useSafeInteger = (_value: SafeInteger) => {
// No need to validate in case of non-integer, NaN, integer-like string, etc.
}
// Validate.
{
if (isSafeInteger(unknownValue)) {
useSafeInteger(unknownValue)
}
}
// Cast.
{
const value: SafeInteger | null = asSafeInteger(unknownValue)
if (value != null) {
useSafeInteger(value)
}
}
// Convert.
{
const value: SafeInteger | null = toSafeInteger("42")
if (value != null) {
useSafeInteger(value)
}
}ES module
import ... from "safe-integer-ts/esm"
// ^^^^