fix: use IEC units for binary sizes (#2901)

This commit is contained in:
3gf8jv4dv
2026-07-09 09:40:19 +08:00
committed by GitHub
parent f3fbbb3720
commit c0dd64c71c
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -34,7 +34,7 @@ function fm(value) {
exports.sizeFormate = size => {
// https://gist.github.com/thomseddon/3511330
if (!size) return '0 b'
let units = ['b', 'kB', 'MB', 'GB', 'TB']
let units = ['B', 'KiB', 'MiB', 'GiB', 'TiB']
let number = Math.floor(Math.log(size) / Math.log(1024))
return `${(size / Math.pow(1024, Math.floor(number))).toFixed(2)} ${units[number]}`
}