(bytes: number)
| 483 | .then((res) => res.json()); |
| 484 | |
| 485 | const formatMemory = (bytes: number) => { |
| 486 | const units = ['B', 'KB', 'MB', 'GB']; |
| 487 | let size = bytes; |
| 488 | let unitIndex = 0; |
| 489 | while (size >= 1024 && unitIndex < units.length - 1) { |
| 490 | size /= 1024; |
| 491 | unitIndex++; |
| 492 | } |
| 493 | return `${Math.round(size * 100) / 100}${units[unitIndex]}`; |
| 494 | }; |
| 495 | |
| 496 | const formatNumber = (num: number) => { |
| 497 | return num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ','); |