(bytes: number)
| 51 | * @returns A string representing the formatted size. |
| 52 | */ |
| 53 | export function formatDocSize(bytes: number): string { |
| 54 | if (bytes === 0) return '0 bytes'; |
| 55 | |
| 56 | if (bytes < 1024) { |
| 57 | return bytes.toFixed(2) + ' bytes'; |
| 58 | } else if (bytes < 1024 * 1024) { |
| 59 | const fileSizeInKB = bytes / 1024; |
| 60 | return fileSizeInKB.toFixed(2) + ' KB'; |
| 61 | } else { |
| 62 | const fileSizeInMB = bytes / (1024 * 1024); |
| 63 | return fileSizeInMB.toFixed(2) + ' MB'; |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | /** |
| 68 | * Validates the given memory name. |
no outgoing calls
no test coverage detected