This is a work-in-progress JavaScript/Node.js implementation of BARE.
The idea so far is, that the parser and converter will run with node.js, while the resulting JavaScript classes should be usable in any JavaScript environment.
Have a look at examples.js
on how to create type definitions in code for now.
Or peek inside the lib-bare.js
, where all conversion classes are located.
These are to be used directly when defining your own type.
Whenever a type takes some sort of arguments, they are static variables right at the top,
just make sure to set them correctly since there are, as of now, no integrity checks on them.
###What is still missing
###A note about Number and 64 bits
Javascript is a wonderful language, and as such it doesn't use an integer type for numbers.
Instead, every single number is stored as a double precision float.
This limits the usable range of integers to 53 bits, which means the maximum unsigned value is just over 9 quadrillion (10^15)
.
There is the BitInt type that allows arbitrary large integers.
But it has limitations; you can't use them in Math functions or beside regular Numbers.
Keep this in mind when using the variable length, and the 64 bit integer types, since these return a BigInt by default.
The lib provides safeNumber
which will convert a BigInt to Number if it fits into 53 bits, or throw an Error if it does not fit if you just need a little more headroom.