(bytes: number, decimals = 2)
| 74 | ]; |
| 75 | |
| 76 | const formatBytes = (bytes: number, decimals = 2) => { |
| 77 | if (!+bytes) return '0 Bytes'; |
| 78 | const k = 1024; |
| 79 | const dm = decimals < 0 ? 0 : decimals; |
| 80 | const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB']; |
| 81 | const i = Math.floor(Math.log(bytes) / Math.log(k)); |
| 82 | return `${parseFloat((bytes / Math.pow(k, i)).toFixed(dm))} ${sizes[i]}`; |
| 83 | }; |
| 84 | |
| 85 | const TAB_COLORS: Record<TabColor, { active: string; dot: string }> = { |
| 86 | green: { active: 'bg-white text-gray-800 shadow-sm', dot: 'bg-gray-500' }, |
no test coverage detected