Skip to content

Return null instead of NaN for unit config key names#70

Merged
dy merged 1 commit into
jkroso:masterfrom
spokodev:fix/config-keys-return-nan
Jul 8, 2026
Merged

Return null instead of NaN for unit config key names#70
dy merged 1 commit into
jkroso:masterfrom
spokodev:fix/config-keys-return-nan

Conversation

@spokodev

@spokodev spokodev commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

parse.unit keeps the group, decimal and placeholder config values on the same object as the unit multipliers. When an input token matches one of those names, parse.unit[units] resolves to a string (e.g. ',') instead of undefined, so n * units evaluates to NaN and the function returns NaN rather than null:

parse('1group')       // NaN  (expected null)
parse('1decimal')     // NaN  (expected null)
parse('1placeholder') // NaN  (expected null)

Only accumulate a component when the resolved unit is a number, so config-key names are treated as unknown units.

@dy
dy merged commit 1a6a94e into jkroso:master Jul 8, 2026
3 checks passed
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.

2 participants