@chbphone55/pretty-bytes
Version:
Format sizes from bytes to human readable strings
3 lines (2 loc) • 459 B
JavaScript
var t=[["B","bytes"],["KiB","kibibytes"],["MiB","mebibytes"],["GiB","gibibytes"],["TiB","tebibytes"],["PiB","pebibytes"],["EiB","exbibytes"],["ZiB","zebibytes"],["YiB","yobibytes"]];exports.UNITS=t,exports.format=function(i,e){void 0===e&&(e="en");var b=i<0?"-":"";i=Math.abs(i);var o=Math.min(Math.floor(Math.log2(i||1)/10),t.length);return[b+parseFloat((i/Math.pow(1024,o)||0).toFixed(3)).toLocaleString(e)].concat(t[o])};
//# sourceMappingURL=index.js.map