diff --git a/utilities/FormattingUtility.ts b/utilities/FormattingUtility.ts index b37cd87..eefda53 100644 --- a/utilities/FormattingUtility.ts +++ b/utilities/FormattingUtility.ts @@ -1,4 +1,4 @@ -const SPACE_VALUES = ["B", "KB", "MB", "GB", "TB", "PB", "EB"]; +const SPACE_VALUES = ["B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB"]; export default class FormattingUtility { public static NumberHumanReadable(num: number) { @@ -7,6 +7,10 @@ export default class FormattingUtility { // HSNOTE: Assumes bytes! public static NumberAsFileSize(num: number) { + if (num < 1024) { + return `${num.toFixed(2)} ${SPACE_VALUES[0]}`; + } + // Converts space values to lower values e.g MB, GB, TB etc depending on the size of the number let i = 1; // Loop through until value is at it's lowest