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

Replace formatNumber with toLocaleString #682

Closed
raineorshine opened this issue May 22, 2020 · 6 comments · Fixed by #700
Closed

Replace formatNumber with toLocaleString #682

raineorshine opened this issue May 22, 2020 · 6 comments · Fixed by #700
Labels
refactor Refactor without changing behavior
Projects

Comments

@raineorshine
Copy link
Contributor

raineorshine commented May 22, 2020

#656 (review)

@raineorshine raineorshine added the refactor Refactor without changing behavior label May 22, 2020
@anmolarora1
Copy link
Collaborator

The current function doesn't seem to have a handler for non-numbers.
formatNumber('abcdef') returns abc,def

Now that we're refactoring it, we might want to fix that. How should the function handle such (non-number) inputs?

@raineorshine
Copy link
Contributor Author

Now that we're refactoring it, we might want to fix that. How should the function handle such (non-number) inputs?

What do you recommend? I always like to hear your idea first, unless you're truly stumped.

@anmolarora1
Copy link
Collaborator

Now that we're refactoring it, we might want to fix that. How should the function handle such (non-number) inputs?

What do you recommend? I always like to hear your idea first, unless you're truly stumped.

Based on it's existing usage, I'd suggest we should ignore invalid/NAN inputs and return 0 in such cases.

@raineorshine
Copy link
Contributor Author

Okay, that's an option. I'm a little concerned that that might allow some invalid usage to slip through. Wouldn't it be better to return null or throw an error?

@anmolarora1
Copy link
Collaborator

anmolarora1 commented May 25, 2020 via email

@raineorshine
Copy link
Contributor Author

raineorshine commented May 25, 2020

Makes sense that it should only accept number. The caller is responsible for converting a serialized number to an actual number.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor Refactor without changing behavior
Projects
No open projects
To Do
Done
Development

Successfully merging a pull request may close this issue.

2 participants