Closed zdm closed 3 years ago
Hi!
That's a good question actually. I'm wondering whether we should:
What is your opinion in this?
That being said, you should already be able to use the same trick as with JSON.stringify()
(here):
BigInt.prototype.toJSON = function() { return this.toString() }
BigInt.asUintN has limitations to the number of bits - in some cases we can lost data.
I think better is to encode / decode using custom extension type. Send it as string, and decode to BigInt.
so, what do you think?
Yes, I think the best way is to add support for custom extensions (also requested in https://github.com/darrachequesne/notepack/issues/18).
I won't have much time for that in the short term though, would you have time to implement it? I'll be happy to merge it :+1:
What extension type in hex can be taken for this? Are you already use any numbers from this range [0, 127] (application-specific types)?
I will take 0x01
for BigInt
.
PR ready.
Hi, Is it possible to add support to encode BigInt as strings trransparently?
Something like this:
If this is acceptable, I can create pull request.