diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-13 12:08:27 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-13 12:08:27 +0300 |
commit | 15ae4a8da83661f2b714d804721001a53b354d28 (patch) | |
tree | 91080b2b969a66857d78fb9008c1d0c367132a8d /app/assets/javascripts/lib | |
parent | 8f71e69fdbb65d2cf95cf16ef5a0add0919edb45 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/lib')
-rw-r--r-- | app/assets/javascripts/lib/utils/constants.js | 1 | ||||
-rw-r--r-- | app/assets/javascripts/lib/utils/number_utils.js | 14 |
2 files changed, 14 insertions, 1 deletions
diff --git a/app/assets/javascripts/lib/utils/constants.js b/app/assets/javascripts/lib/utils/constants.js index 993d51370ec..1a4ecc12f01 100644 --- a/app/assets/javascripts/lib/utils/constants.js +++ b/app/assets/javascripts/lib/utils/constants.js @@ -1,4 +1,5 @@ export const BYTES_IN_KIB = 1024; +export const BYTES_IN_KB = 1000; export const HIDDEN_CLASS = 'hidden'; export const TRUNCATE_WIDTH_DEFAULT_WIDTH = 80; export const TRUNCATE_WIDTH_DEFAULT_FONT_SIZE = 12; diff --git a/app/assets/javascripts/lib/utils/number_utils.js b/app/assets/javascripts/lib/utils/number_utils.js index bc87232f40b..2424d6cbf3b 100644 --- a/app/assets/javascripts/lib/utils/number_utils.js +++ b/app/assets/javascripts/lib/utils/number_utils.js @@ -1,4 +1,4 @@ -import { BYTES_IN_KIB } from './constants'; +import { BYTES_IN_KIB, BYTES_IN_KB } from './constants'; import { sprintf, __ } from '~/locale'; /** @@ -35,6 +35,18 @@ export function formatRelevantDigits(number) { } /** + * Utility function that calculates KB of the given bytes. + * Note: This method calculates KiloBytes as opposed to + * Kibibytes. For Kibibytes, bytesToKiB should be used. + * + * @param {Number} number bytes + * @return {Number} KiB + */ +export function bytesToKB(number) { + return number / BYTES_IN_KB; +} + +/** * Utility function that calculates KiB of the given bytes. * * @param {Number} number bytes |