Int
APIA tagged type to represent integer values
Motivation
There is no int in ES only number. Nevertheless, there is a notion of Safe Integer which represent an integer value in the range -2^53 to (2^53)-1, without any precision loss.
Int is a Tag type that helps to validate at compile time that the value is a "safe integer".
Usage
import { Int } from '@w5s/core'
const one = Int(1);
const two = Int(2);
const three = Int['+'](one, two); // 3
Coding Guide
tip
Prefer Int for type safety except when performance are critical
Intfunctions are designed to perform integer operations in a type safe way and represent explicitly all possible errors (parsing errors, division by zero, etc)Intfunctions will never have better performance than inline regularnumberoperation