~kiito/bare-js

4b1ba720c5eecb985a55cb8f2336a118e1d60ecc — Emma 4 months ago 63ba702
Readme formatting
1 files changed, 9 insertions(+), 9 deletions(-)

M README.md
M README.md => README.md +9 -9
@@ 4,25 4,25 @@ This is a work-in-progress JavaScript/Node.js implementation of [BARE](https://b

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.\
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.\
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
 * The schema to js translator
 * Union and Enum types\
 * The schema to js translator.
 * Union and Enum types.  
   These are difficult to translate to js, so I'm going to have to think about use cases and how to make them convenient to use
 * Conversion error handling and integrity verification
 * Unit tests, these will come last
 * Conversion error handling and integrity verification.
 * Unit tests, these will come last.

###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)`.\
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](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt) 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.\
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.