(bytes, digits = 2)
| 9 | export const kMicro2Milli = 1 / 1000; |
| 10 | |
| 11 | export function formatBytes(bytes, digits = 2) { |
| 12 | const units = ['B', 'KiB', 'MiB', 'GiB']; |
| 13 | const divisor = 1024; |
| 14 | let index = 0; |
| 15 | while (index < units.length && bytes >= divisor) { |
| 16 | index++; |
| 17 | bytes /= divisor; |
| 18 | } |
| 19 | return bytes.toFixed(digits) + units[index]; |
| 20 | } |
| 21 | |
| 22 | export function formatMicroSeconds(micro) { |
| 23 | return (micro * kMicro2Milli).toFixed(1) + 'ms'; |
no outgoing calls
no test coverage detected
searching dependent graphs…