long.js
long.js copied to clipboard
Support BigInt
The builtin BigInt type is supported in many browsers and in NodeJS (such as the fs.stat API).
Current behavior is particularly spurious and can cause bugs: Long.fromValue(55n) results in 0
Please consider adding support for BigInt or if you'd rather accept contributions I'd be happy to take a look.
I maybe think it should rather be suggested that BigInt is used instead of long?
In longfn I implemented BigInt for the from/toBytes methods:
toBigInt(fromBytesLE(bytes,...))
But independently of that, I think it is a good idea to have a int64 implementation handy when needing to be computationally compatible to other implementations. With BigInt buffer overflows don't exist...