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

Stricter number parsing in Float.fromString and Int.fromString #93

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

glennsl
Copy link
Contributor

@glennsl glennsl commented Mar 7, 2023

Implements the changes proposed in #86. See the differences in the tests for specifics on behavioural changes.

Note also that this drops the radix option of Int.toString, but on the other hand improves parsing of radix prefixes in the string itself, i.e. 0x, 0o and 0b.

@glennsl glennsl changed the title Feat/stricter number parsing Stricter number parsing in Float.fromString and Int.fromString Mar 7, 2023
@zth zth added this to the 0.3.0 milestone Mar 9, 2023
@jmagaram
Copy link
Contributor

Got a big laugh reading this. Especially “worst of all the bad options”. And interesting to learn there is a Number object distinct from the primitive - glad to have that in my toolbox. A couple thoughts…

Group them together so the user will see a menu of related choices. So parseString not fromString. If you want to encourage use of your implementation call it parse.

In the doc help for each explain the limitations and behavior like “Unreliable behavior if the string includes separators or characters not part of the number.” Give a few bad examples. Point to MDN.

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

Successfully merging this pull request may close these issues.

3 participants