-
Notifications
You must be signed in to change notification settings - Fork 203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add BigInt support #58
Conversation
63927ad
to
3ddedb4
Compare
Does this work with native |
True, I didn't test it earlier. Not sure how dificult it would be to add support for negative numbers for numbers, hex and bigints. |
Removed throws: normalized return values.
Tested with native |
Seeing as its over a month now, you should publish this to NPM. Override the You can always deprecate the |
It seams a good idea, but it will need more work, currently I was using the BigInt to Hex and encodeHex function, but aparently the @ivanakimov implementation of
I didn't expect this behavior, I will try to take a look and do at least So, it might take change all |
I've deviced a workaround with hex using Encode: Decode: |
Thanks for experimenting with this, everyone. There have been some requests in the past for supporting bigger numbers, but I haven't noticed many lately. It's true, we've tried to avoid depending on other modules to keep the codebase small and less complex, so the advice has usually been to split up the numbers yourself (if they're too big) before encoding. But I agree that having built-in support would of course be ideal. If there's a way to use JavaScript's Otherwise, feel free to fork or build on top of Hashids, and I'll link to your repo on the website. |
@ivanakimov interested in it for node, which supports |
@Bessonov I'll look into it. I'm curious - what's your use case? |
I want to switch to CockroachDB, which offers some compatibility with Postgresql and stores primary key as 64-bit integer. Currently, the |
Thanks a lot @prodrigestivill for your proposal. I have decided it would be best if the BigInt support were transparent (rather than using a custom function for it). A beta version with BigInt support (using standard APIs) is released as Looking forward to your feedback! |
🎉 This issue has been resolved in version 2.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
As a proposal it would be helpfull to have calls to handle bigint in case of handling Big Integer Ids from a DB.
I implemented initially using npm big-integer library.
I also implemented as a complementary library on my repository hashids-bigint.
This library is not yet published to npm, because I believe it would be better to have support in the same library.
Let me know what do you think, I undestand that adding an optional dependency might not be desirable.
Possible solutions: