0

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.

gabomgp
  • 769
  • 1
  • 10
  • 23
  • It is not good idea. For example: Javascript don't support operator overloading, that means every operation with numbers must be done by methods.... – Misaz Nov 10 '16 at 06:05
  • the probem with operator overloading is'nt too important. If i can use the native data types, maybe with webassembly integration or something... – gabomgp Nov 10 '16 at 12:24

0 Answers0