fix: more intuitive byte formatting boundaries for rounding (#8840) · npm/cli@f2c3af7 · GitHub
Skip to content

Commit f2c3af7

Browse files
authored
fix: more intuitive byte formatting boundaries for rounding (#8840)
## WHY/WHAT Fixed non-intuitive unit rounding for byte formatting. Previously, values close to a unit boundary (e.g. 999,999 B) displayed incorrectly as the smaller unit. We adjusted the conversion threshold (e.g. to 999,950 B for MB) to leverage standard `toFixed(1)` rounding, ensuring values that are `almost 1.0` of the next unit are correctly displayed as 1.0 MB, prioritizing a better user experience.
1 parent 6d1db87 commit f2c3af7

2 files changed

Lines changed: 36 additions & 2 deletions

File tree

lib/utils/format-bytes.js

Lines changed: 2 additions & 2 deletions

test/lib/utils/tar.js

Lines changed: 34 additions & 0 deletions

0 commit comments

Comments
 (0)