qsu
Version:
qsu is a utility library that contains useful and frequently used functions. Start with your preferred language and the modern development environment.
1 lines • 250 B
JavaScript
export function fileSizeFormat(t,o=2,e=!1){const B=["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"];if(t<1)return`0 ${B[0]}`;const r=Math.floor(Math.log(t)/Math.log(1024)),a=t/1024**r;return`${e?Math.ceil(a):parseFloat(a.toFixed(o<0?0:o))} ${B[r]}`}