Git Product home page Git Product logo

Comments (7)

ullmark avatar ullmark commented on August 17, 2024 1

@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.

ullmark avatar ullmark commented on August 17, 2024

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.

ullmark avatar ullmark commented on August 17, 2024

... or maybe it shouldn't throw at all but just return an empty array...

from hashids.net.

jonnystoten avatar jonnystoten commented on August 17, 2024

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.

casserlyprogramming avatar casserlyprogramming commented on August 17, 2024

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.

jonnystoten avatar jonnystoten commented on August 17, 2024

@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.

manigandham avatar manigandham commented on August 17, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.