diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-16 21:25:58 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-16 21:25:58 +0300 |
commit | a5f4bba440d7f9ea47046a0a561d49adf0a1e6d4 (patch) | |
tree | fb69158581673816a8cd895f9d352dcb3c678b1e /app/assets/javascripts/lib/utils/number_utils.js | |
parent | d16b2e8639e99961de6ddc93909f3bb5c1445ba1 (diff) |
Add latest changes from gitlab-org/gitlab@14-0-stable-eev14.0.0-rc42
Diffstat (limited to 'app/assets/javascripts/lib/utils/number_utils.js')
-rw-r--r-- | app/assets/javascripts/lib/utils/number_utils.js | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/app/assets/javascripts/lib/utils/number_utils.js b/app/assets/javascripts/lib/utils/number_utils.js index e3500d02a79..f3dedb7726a 100644 --- a/app/assets/javascripts/lib/utils/number_utils.js +++ b/app/assets/javascripts/lib/utils/number_utils.js @@ -72,11 +72,13 @@ export function bytesToGiB(number) { * @returns {String} */ export function numberToHumanSize(size) { - if (size < BYTES_IN_KIB) { + const abs = Math.abs(size); + + if (abs < BYTES_IN_KIB) { return sprintf(__('%{size} bytes'), { size }); - } else if (size < BYTES_IN_KIB * BYTES_IN_KIB) { + } else if (abs < BYTES_IN_KIB ** 2) { return sprintf(__('%{size} KiB'), { size: bytesToKiB(size).toFixed(2) }); - } else if (size < BYTES_IN_KIB * BYTES_IN_KIB * BYTES_IN_KIB) { + } else if (abs < BYTES_IN_KIB ** 3) { return sprintf(__('%{size} MiB'), { size: bytesToMiB(size).toFixed(2) }); } return sprintf(__('%{size} GiB'), { size: bytesToGiB(size).toFixed(2) }); |