(bytes: bigint)
| 36 | const MAX_LAG_MS = 86_400_000; |
| 37 | |
| 38 | export function humanizeBytes(bytes: bigint): { |
| 39 | value: number; |
| 40 | unit: ByteUnit; |
| 41 | } { |
| 42 | if (bytes < kilobyte) { |
| 43 | return { value: Number(bytes), unit: "B" }; |
| 44 | } else if (bytes < megabyte) { |
| 45 | return { value: Number(bytes) / Number(kilobyte), unit: "KB" }; |
| 46 | } else if (bytes < gigabyte) { |
| 47 | return { value: Number(bytes) / Number(megabyte), unit: "MB" }; |
| 48 | } else if (bytes < terabyte) { |
| 49 | return { value: Number(bytes) / Number(gigabyte), unit: "GB" }; |
| 50 | } else { |
| 51 | return { value: Number(bytes) / Number(terabyte), unit: "TB" }; |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | export const formatBytesShort = (bytes: bigint) => { |
| 56 | const { value, unit } = humanizeBytes(bytes); |
no outgoing calls
no test coverage detected