Add initial project files

This commit is contained in:
Igor Martyniuk
2026-09-01 13:03:41 +03:00
parent 22e111bb44
commit 74cb5b6176
1841 changed files with 242819 additions and 30 deletions
+12
View File
@@ -0,0 +1,12 @@
const thresh = 1024;
export function bytesToHumanReadableFormat(bytes: number, units: string[] = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']): string {
let bytesCopy = bytes;
if (bytesCopy < thresh) return `${bytesCopy} ${units[0]}`;
let u = -1;
do {
bytesCopy /= thresh;
++u;
} while (bytesCopy >= thresh && u + 1 < units.length - 1);
return `${bytesCopy.toFixed(1)} ${units[u + 1]}`;
}