UNPKG

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 225 B
export function getFileSize(t,o=2){const e=["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"];if(t<1)return`0 ${e[0]}`;const B=Math.floor(Math.log(t)/Math.log(1024));return`${parseFloat((t/1024**B).toFixed(o<0?0:o))} ${e[B]}`}