aboutsummaryrefslogtreecommitdiff
path: root/src/util/bytes.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/bytes.ts')
-rw-r--r--src/util/bytes.ts5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/util/bytes.ts b/src/util/bytes.ts
new file mode 100644
index 0000000..43ad49c
--- /dev/null
+++ b/src/util/bytes.ts
@@ -0,0 +1,5 @@
+export const formatBytes = (n: number): string => {
+ if (n >= 1_048_576) return `${(n / 1_048_576).toFixed(1)} MB`;
+ if (n >= 1024) return `${(n / 1024).toFixed(1)} KB`;
+ return `${n} B`;
+};