node-gtk icon indicating copy to clipboard operation
node-gtk copied to clipboard

Support BigInt conversion

Open romgrk opened this issue 6 years ago • 4 comments

Links:

  • https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt

romgrk avatar Nov 05 '19 20:11 romgrk

How would you go about this? I know it would be a breaking change if node-gtk suddenly started returning BigInt values for int64, since they don't mix with numbers... but the current behaviour (silently casting to double and returning a completely different number) is also broken. Options that come to mind:

  • Maybe it's feasible to release a major version soon?
  • We could start returning BigInt, but just in cases where the number can't be represented by a double. If this breaks something, it was surely broken already, and new users would BigInt(x) to get the good behaviour.

mildsunrise avatar Apr 18 '21 16:04 mildsunrise

Maybe it's feasible to release a major version soon?

We're still pre-1.0, so we can do anything we want :smile: Joke aside, yes, and it would be nice to have a major release, so people can rely on a stable API. TBH I've been reticent to publish a 1.0 because I wasn't confident enough in this being production-ready, OTOH the issues can be communicated clearly in the readme.

We could start returning BigInt, but just in cases where the number can't be represented by a double. If this breaks something, it was surely broken already, and new users would BigInt(x) to get the good behaviour.

Very sensible behavior, it indeed makes sense that people are forced to migrate away from a broken implementation.

So sure, as soon as BigInt conversion is implemented for the remaining types (GTypes are already converted as BigInt) we can release a 1.0.

romgrk avatar Apr 18 '21 19:04 romgrk

Good to know, I'll keep it in mind. Let's see if I have time to work on this...

mildsunrise avatar Apr 18 '21 21:04 mildsunrise

I'd be happy to have another contributor ^^

AFAICT, all the changes that would be needed would be in value.cc, which is where we do all our conversions, plus updating the failing tests (or adding some if nothing fails).

romgrk avatar Apr 18 '21 21:04 romgrk