msgpack-javascript
msgpack-javascript copied to clipboard
Unable to pack int 64
Hello, when I packaged "number", I could not package "int64". After I checked the source code, I changed "Number.isSafeInteger(object)" to "object.toString().indexOf('.') <0" It is temporarily solved. Obviously this is not the best method, but it can temporarily solve my problem. If there is a better solution to identify ”int64“, I hope to inform, thanks
This is because there's no int64 in JavaScript. A number that Number.isSafeInteger() returns false is NOT a precise integer (or not a "safe" integer) so that you should not deal it as integers but instead it is a floating point number.
If you need larger integers than "safe" integers, you have to use bigint. There's no direct support for bigint right now, but you can easily handle it. Seel https://github.com/msgpack/msgpack-javascript#handling-bigint-with-extensioncodec for details.