Skip to content

fix: handle formatBytes edge cases#16

Open
Jaco-Ren wants to merge 1 commit into
OpenNSWM-Lab:mainfrom
Jaco-Ren:codex/fix-formatbytes-edge-cases
Open

fix: handle formatBytes edge cases#16
Jaco-Ren wants to merge 1 commit into
OpenNSWM-Lab:mainfrom
Jaco-Ren:codex/fix-formatbytes-edge-cases

Conversation

@Jaco-Ren

Copy link
Copy Markdown

Summary

Fixes formatBytes edge cases reported in #15:

  • return an explicit placeholder for negative or non-finite byte values
  • keep fractional byte values in the B unit instead of producing undefined
  • add PB and EB units and clamp the selected unit index for very large values
  • add a focused Vitest regression test for zero, byte, PB/EB, invalid, fractional, and beyond-EB inputs
  • add the missing Vitest setup file referenced by vite.config.ts

This differs from the existing #13 by covering the >= 1 PiB case and preserving the invalid-size placeholder behavior requested in #15.

Verification

npm.cmd test -- --run src/lib/utils.test.ts
npm.cmd run typecheck
npm.cmd run build

I also checked the touched files with ESLint. The full existing lint command still reports pre-existing no-explicit-any errors in src/components/code/BlueprintGraph.tsx, unrelated to this change.

Fixes #15

@Jaco-Ren Jaco-Ren closed this Jun 29, 2026
@Jaco-Ren Jaco-Ren reopened this Jun 29, 2026
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.

formatBytes returns wrong unit for >= 1 PiB and crashes on negative/NaN

1 participant