Skip to content

fix: handle large sizes and long strings in formatters - #183

Merged
bartveneman merged 2 commits into
mainfrom
claude/formatter-edge-cases
Nov 9, 2026
Merged

bartveneman merged 2 commits into
mainfrom
claude/formatter-edge-cases

Conversation

@bartveneman

@bartveneman bartveneman commented Nov 9, 2026 •

Copy link
Copy Markdown
Member
  • to_filesize: format with Intl.NumberFormat units (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 render undefined. 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 a RangeError when the string is longer than the pad length.
  • Adds formatters.test.ts.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Package Size Increase

📦 Package 📏 Base Size 📏 Source Size 📈 Size Change
wallace-cli 4.7 kB 4.9 kB +143 B

Comment thread src/formatters.ts
@@ -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 {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
@bartveneman
bartveneman merged commit 43a6738 into main Nov 9, 2026
10 checks passed
@bartveneman
bartveneman deleted the claude/formatter-edge-cases branch November 9, 2026 19:47
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