Repository navigation
fix: honor locale and separator options for zero values - #364
Merged
avoidwork merged 2 commits intoOct 11, 2026
Merged
Conversation
Owner
|
Thanks for this fix — it's shipped in v11.0.26. The zero-value path now honors locale, localeOptions, and separator consistently with the non-zero path. Appreciate the contribution! 🙏 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The zero-value fast path bypasses number formatting options. For example,
filesize(0, { locale: "de-DE", pad: true })returns0.00 Bwhile nonzero values use the requested comma decimal separator. Empty upload sizes therefore render inconsistently with populated sizes.Pass locale, localeOptions, and separator into zero handling and reuse the shared number formatter. Preserve the existing precision-over-padding priority, exponent output, symbol/full-form handling, and default numeric zero in structured outputs. Regenerated the tracked distributions.
Type of Change
Related Issues
N/A — independently reproduced; no overlapping open PR found.
Testing
The zero-formatting and locale-plus-precision regressions failed before their fixes (
0.00 Brather than0,00 B) and passes afterward. It covers numeric/BigInt zero, explicit/system locale, localeOptions, custom separator, precision, array/object output, and unchanged exponent output. Explicit precision retains the existing precision string (for example0.00 Bwith de-DE), matching the existing nonzero precision path; only zeros without explicit precision are converted to numbers for locale formatting.node --test --experimental-test-coverage tests/**/*.js: 268 of 269 tests pass; source files retain 100% line/branch/function coverage. The remaining existing test assumes the system locale uses a period (should ignore localeOptions when locale is true). On this Windows machine the system locale is tr-TR, so it produces1,54 kB. Re-running that test against the original HEAD source confirms the identical failure.Oxlint passes for source/tests/build configuration, and their oxfmt check passes.
npm run buildpasses. The aggregatenpm testformatting glob additionally visits generated dist files on Windows and reports existing formatting differences; the targeted formatter also finds an existing benchmarks/README.md difference. Those unrelated files were not reformatted.Checklist
npm testpasses — existing locale/formatting limitations described abovenpm run buildsucceedsScreenshots (if applicable)
N/A