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

Specify and document a precedence when a postfix can have serveral meanings #593

Open
chaosflaws opened this issue Mar 17, 2021 · 2 comments

Comments

@chaosflaws
Copy link
Contributor

While working on #590, I came across ambiguities in the unformatter.

Initially, I tried to use B as the abbreviation for "trillion", as that would be "Billion" in German. This, however, made some tests fail, as B is also a valid postfix in the byte unformatter, representing bytes.

Obviously, numbro cannot solve this problem completely, as strings like "1B" are inherently ambiguous in German. To migitate the problem, however, it would be possible to:

  • define an order of execution/precedence on the formatters (which kind of formatted number does the unformatter try to recognize first/second/...?) and add this to the docs (http://numbrojs.com/format.html#unformat)
  • make the unformatter take a second argument specifying the type of value in question (number, currency, byte, etc.)
@BenjaminVanRyseghem
Copy link
Owner

Thanks for the report.

Indeed, the unformatter is quite ambiguous and fails more that I dare to admit 😄

I would go for the second approach:

  • it matches better with how format works
  • it could ultimately solves all the issues
  • it's more future-proof

My 2cts 😄

@chaosflaws
Copy link
Contributor Author

I don't think the two approaches are mutually exclusive. Having a unformat function that only takes the input as argument might be useful where the someone has no clue about what kind of numeric thing has been input. We should just make sure the user knows what he can expect from that function.

Anyways, I am sorry I probably won't have time to tackle this (as a matter of fact, I only came here because I need that language file fix two layers up the stream...).

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

2 participants