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