( value: number | null, yAxisUnit: ByteUnit | null, )
| 101 | } |
| 102 | |
| 103 | export const formatValue = ( |
| 104 | value: number | null, |
| 105 | yAxisUnit: ByteUnit | null, |
| 106 | ) => { |
| 107 | if (value === null) return "-"; |
| 108 | |
| 109 | const result = yAxisUnit ? convertBytes(value, yAxisUnit) : value; |
| 110 | const numberFormatter = Intl.NumberFormat("default", { |
| 111 | maximumFractionDigits: decimalDigits(result), |
| 112 | }); |
| 113 | return numberFormatter.format(result); |
| 114 | }; |
| 115 | |
| 116 | export function largestPossibleByteUnit(bytes: number): ByteUnit { |
| 117 | if (bytes < KB) return "B"; |
no test coverage detected