Repository navigation
fix: handle large sizes and long strings in formatters - #183
Merged
Merged
Conversation
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Contributor
|
| 📦 Package | 📏 Base Size | 📏 Source Size | 📈 Size Change |
|---|---|---|---|
| wallace-cli | 4.7 kB | 4.9 kB | +143 B |
bartveneman
commented
Nov 9, 2026
| @@ -5,12 +5,12 @@ let number_formatter = new Intl.NumberFormat() | |||
| * @see https://www.codexworld.com/how-to/convert-file-size-bytes-kb-mb-gb-javascript/ | |||
| */ | |||
| export function to_filesize(bytes: number): string { | |||
Member
Author
There was a problem hiding this comment.
not sure about the Node support, but this would be more ideal: https://raw.githubusercontent.com/projectwallace/projectwallace.com/refs/heads/main/src/lib/format-filesize.ts
Member
Author
There was a problem hiding this comment.
Done: to_filesize now uses Intl.NumberFormat with style: 'unit' (bytes/kB/MB, 3 significant digits), following that reference. unit style needs Node 12+ with full ICU, so engines >=20.12 is fine. Sizes above 1 MB stay in MB (no undefined). Output changed (e.g. 173B → 173 bytes), so I regenerated the fixtures and made the Summary header columns pad to the widest cell so they stay aligned.
Generated by Claude Code
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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.
to_filesize: format withIntl.NumberFormatunits (bytes/kB/MB, 3 significant digits), as suggested in review. Negative values clamp to 0 and sizes above 1 MB stay in MB, so it can no longer renderundefined. Output changes (e.g.173B→173 bytes); fixtures regenerated and the Summary header columns now pad to the widest cell.pad_end/pad_start: no longer throw aRangeErrorwhen the string is longer than the pad length.formatters.test.ts.