Page MenuHomePhorge

file_size_format.js
No OneTemporary

Size
450 B
Referenced Files
None
Subscribers
None

file_size_format.js

const fileSizeFormat = (numArg) => {
const units = ['B', 'KiB', 'MiB', 'GiB', 'TiB']
let num = numArg
if (num < 1) {
return num + ' ' + units[0]
}
const exponent = Math.min(Math.floor(Math.log(num) / Math.log(1024)), units.length - 1)
num = (num / Math.pow(1024, exponent)).toFixed(2) * 1
const unit = units[exponent]
return { num, unit }
}
const fileSizeFormatService = {
fileSizeFormat
}
export default fileSizeFormatService

File Metadata

Mime Type
text/plain
Expires
Thu, Apr 24, 4:21 AM (1 d, 16 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
95985
Default Alt Text
file_size_format.js (450 B)

Event Timeline