in ruler-frontend/src/jsMain/kotlin/com/spotify/ruler/frontend/Formatting.kt [29:37]
fun formatSize(bytes: Number): String {
val units = mutableListOf("B", "KB", "MB", "GB", "TB", "PB")
var remainder = bytes.toDouble()
while (remainder > BYTE_FACTOR) {
remainder /= BYTE_FACTOR
units.removeFirst()
}
return "${remainder.asDynamic().toFixed(1)} ${units.first()}"
}