Sha256: db65044fc5bfe76ff4ab102b5c418c67e4ffb93409c94c7ba741145de83bfce5
Contents?: true
Size: 319 Bytes
Versions: 28
Compression:
Stored size: 319 Bytes
Contents
export function formatFileSize(bytes) { let exponent = bytes === 0 ? 0 : Math.floor(Math.log(bytes) / Math.log(1024)) // prevent format higher than GB if (exponent > 3) { exponent = 3 } let value = (bytes / Math.pow(1024, exponent)).toFixed(2) return value + " " + ["B", "kB", "MB", "GB"][exponent] }
Version data entries
28 entries across 28 versions & 1 rubygems