Comments (7)
@manigandham Hi, I'll look into it although I think returning empty array seems most appropriate given we already do it for other errors.
from hashids.net.
Hi,
Yes, that's obviously not going to work, as you said, Z are not in the alphabet. The question is whether it should throw a more descriptive error or not. I guess that could be good at the cost of needing to enumerate the alphabet and the hash every time to make sure that all characters in the hash exist in the alphabet or not before trying to code.
checking for < 0 might be a solution. But throwing an "Hash Included character not in alphabet"-exception when that happens isn't necessarily true, so don't like that either.
I'll ask the authors of the other port to see if we should have a way of handling this 😄
from hashids.net.
... or maybe it shouldn't throw at all but just return an empty array...
from hashids.net.
Yes, I was not clear, I meant I thought it should return an empty array when the input chars are not in the alphabet! (or any decoded numbers are negative).
from hashids.net.
Personally I think it should throw an error and let the calling application handle that exception. That seems like a better design than arbitrarily returning an empty array.
from hashids.net.
@casserlyprogramming Well, it's not that arbitrary because the same method returns an empty array in other error cases. Better to be consistent!
from hashids.net.
It would be great to have TryDecode
methods that follow the .NET idioms of attempting to parse without throwing an exception.
This is very useful in situations where the input can't be controlled or is unpredictable and avoids the overhead of throwing/catching exceptions.
from hashids.net.
Related Issues (20)
- how to Creates short unique ids from integers. (only positive numbers & zero) HOT 1
- Bug on long encoding with 16 alphabet chars HOT 8
- Using multiple options for encoding/decoding HOT 1
- Attempting to Decode short strings results in incorrect exceptions being produced HOT 7
- Hashids not generating with proper minhashlength HOT 1
- HashIds not working after adding custom Output formatter HOT 2
- How do I get HashIDs of a specific length? HOT 1
- How use id with Guid/UUID/Sequential Guid HOT 1
- Is there a guarantee of encoded sequence uniqueness with differing salts? HOT 4
- Insufficient Variation In Generated HashIds HOT 1
- Document the effective character limit of the salt HOT 5
- Decoding input smaller than minHashLength unhandled exceptions are thrown HOT 4
- Json support? HOT 3
- Regarding HashidsNet HOT 1
- Website seems down HOT 2
- Valid use-case for library? HOT 1
- Is this lib still being maintained? HOT 2
- Decode null string thows NullReferenceException HOT 1
- Same id generated for different integers HOT 3
- Same hash different integers HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hashids.net.