(bytes: number)
| 52 | } |
| 53 | |
| 54 | export function formatBytes(bytes: number) { |
| 55 | const threshold = 1000; |
| 56 | if (Math.round(bytes) < threshold) { |
| 57 | return bytes + " B"; |
| 58 | } |
| 59 | const units = ["kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"]; |
| 60 | let u = -1; |
| 61 | let formattedBytes = bytes; |
| 62 | do { |
| 63 | formattedBytes /= threshold; |
| 64 | u++; |
| 65 | } while (Math.abs(formattedBytes) >= threshold && u < units.length - 1); |
| 66 | return formatNumber(formattedBytes) + " " + units[u]; |
| 67 | } |
| 68 | |
| 69 | export function extractReadableIndex(query: Record<string, any>): string { |
| 70 | if (query.orderBy) { |
no test coverage detected
searching dependent graphs…