Skip to content

fix: preserve the original unit for zero values - #434

Open
wissaaamm wants to merge 1 commit into
avoidwork:masterfrom
wissaaamm:fix/preserve-zero-unit
Open

wissaaamm wants to merge 1 commit into
avoidwork:masterfrom
wissaaamm:fix/preserve-zero-unit

Conversation

@wissaaamm

Copy link
Copy Markdown

Summary

filesize(0, { output: "object", symbols: { B: "octets" } }) currently reports "octets" in both symbol and unit. The public type defines unit as the original symbol before customization, which callers can use as a stable identifier. The zero path reused the display symbol after applying overrides.

Capture the original symbol before customization and use it for unit. The result now has symbol: "octets" and unit: "B". This also applies when a full-form name is selected. Output remains plain text and the patch adds no input handling or dependencies.

Testing

  • Both new public API regressions failed on master and pass with the fix. The cases cover number and bigint zero, and a custom full-form label for bits.
  • All 287 Node.js 24 tests and node --check src/helpers.js passed offline. Line, branch, and function coverage were all 100%.
  • Rollup, oxlint, and oxfmt were unavailable offline. Bundle generation and lint are pending CI.

The implementation and tests were prepared with AI assistance and verified by running the checks above.

This branch has not been deployed

No deployments
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.

1 participant