Skip to content
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

Relax MAX_NUMBER restriction #56

Closed
iggymoran opened this issue Apr 26, 2018 · 6 comments
Closed

Relax MAX_NUMBER restriction #56

iggymoran opened this issue Apr 26, 2018 · 6 comments

Comments

@iggymoran
Copy link

iggymoran commented Apr 26, 2018

I understand the desire to be completely compatible with the Javascript implementation/limitiations, as explained in #47 and in the docs, but is it possible to provide a toggle that disables this functionality?

This would ensure backward compatibility with Javascript's limitations, but would allow this library to make use of the full potential that the Java platform provides.

Other implementations (such as Scala and .Net) don't impose these restrictions and allow the library to be used with the native implementation of the number.

@arcticicestudio
Copy link

arcticicestudio commented Apr 26, 2018

I've also proposed this in another issue some time ago and if I remember correctly they planed a v2 which will include some breaking changes like this, but I implemented my own library including this feature. I've found no reason to limit a Java implementation only because the reference algorithm implementation is limited by the chosen language.
This library is used within the Java world and even if generated Hashids are e.g. used in a REST API to disguise internal database IDs which will be consumed by a JavaScript frontend, the part of the "decryption" will be handed in the backend (this library) while the frontend handles the Hashid as simple string and not a number.

@0x3333
Copy link
Collaborator

0x3333 commented Apr 26, 2018

The initial proposal was to be interoperable. See #55

@0x3333 0x3333 closed this as completed Apr 26, 2018
@arcticicestudio
Copy link

Might be interesting that there is a new TC39 proposal that introduces BigInt to JavaScript, so the current limit will be kind of obsolete.

@fanweixiao
Copy link
Member

@arcticicestudio I think we should follow hashids main project spec, to keep exact result in different languages.

@0x3333
Copy link
Collaborator

0x3333 commented May 3, 2018

I was thinking about this issue, and I believe that the best path is to allow bigger numbers when the user explicitly allow incompatibility with the original spec. This way we can have a version that follows the original implementation and also allows users to loosen up the spec a bit. Something like "strict mode", which is compatible with the original spec, and a "relaxed mode" which is more javaish.

@fanweixiao
Copy link
Member

fanweixiao commented May 3, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants