maxdavidson / structly

Tool for working with binary data types in JavaScript
MIT License
14 stars 1 forks source link

Int64 Support #103

Closed peteroreil closed 6 years ago

peteroreil commented 7 years ago

Is there a way of dealing with 64bit integers. Can you encode raw buffers with structly?

maxdavidson commented 6 years ago

You could either do it with a raw buffer once the alignment can be configured, or by using an ugly hack to modify a struct schema like this:

const uint64be = Object.assign(struct({ lo: uint32be, hi: uint32be }), { byteAlignment: 8 })
const uint64le = Object.assign(struct({ hi: uint32le, lo: uint32le }), { byteAlignment: 8 })

In the future, I could maybe implement an arbitrary length integer using BigInt.

peteroreil commented 6 years ago

Thanks for the reply and workaround