I want to write a library in typescript that serialize/deserialize native numeric types, among others data types. The idea is to have a class as it:
class Rectangle
{
x: i32
y: i32
width: u32
height: u32
}
And serialize it to binary, then deserialize it. I want the value deserialized dont lose precision, and (if posible) to be efficent in memory and processor usage. I want the fields to be type-safe.
Currently, my i32 and u32 types are:
interface u32
{
value: number;
}
interface i32
{
value: number;
}
That is type safe, but not perfomant (the operations over value are using doubles not native integer of 32 bits) or precise (doubles not integers).
Then, is there any type-safe, efficent and both server/browser compatible manner of use numeric native data types?
P.D. Sorry my english.