refactor: reorganize project structure and improve user command handling

This commit is contained in:
grngxd 2025-07-31 19:25:31 +01:00
parent 5cfcb3ba0c
commit 49d6b51de6
7 changed files with 64 additions and 26 deletions

13
lib/files.ts Normal file
View file

@ -0,0 +1,13 @@
export const formatSize = (bytes: number): string => {
const units = ["B", "KB", "MB", "GB", "TB"];
let size = bytes;
let unit = units[0];
for (let i = 0; i < units.length; i++) {
if (size < 1024 || i === units.length - 1) {
unit = units[i];
break;
}
size /= 1024;
}
return `${size % 1 === 0 ? size : size.toFixed(2)} ${unit}`;
}