From c0dd64c71cefa909f8d4144e548d532ed587e985 Mon Sep 17 00:00:00 2001 From: 3gf8jv4dv <3gf8jv4dv@gmail.com> Date: Thu, 9 Jul 2026 09:40:19 +0800 Subject: [PATCH] fix: use IEC units for binary sizes (#2901) --- publish/utils/index.js | 2 +- src/common/utils/common.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/publish/utils/index.js b/publish/utils/index.js index 24e495ec..cfc8a905 100644 --- a/publish/utils/index.js +++ b/publish/utils/index.js @@ -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]}` } diff --git a/src/common/utils/common.ts b/src/common/utils/common.ts index 2f12c3a2..b5fbbfe8 100644 --- a/src/common/utils/common.ts +++ b/src/common/utils/common.ts @@ -12,7 +12,7 @@ export const getRandom = (min: number, max: number): number => Math.floor(Math.r export const sizeFormate = (size: number): string => { // 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]}` }