forked from tdewin/rps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
filesize.min.js
10 lines (10 loc) · 1.16 KB
/
filesize.min.js
1
2
3
4
5
6
7
8
9
10
/*
2014 Jason Mulligan
@license BSD-3 <https://raw.github.com/avoidwork/filesize.js/master/LICENSE>
@link http://filesizejs.com
@module filesize
@version 2.0.4
*/
(function(p){function g(g,c){var b="",d=0,a,h,m,f,n,e,k,l;if(isNaN(g))throw Error("Invalid arguments");c=c||{};h=!0===c.bits;e=!0===c.unix;d=void 0!==c.base?c.base:e?2:10;n=void 0!==c.round?c.round:e?1:2;k=void 0!==c.spacer?c.spacer:e?"":" ";l=void 0!==c.suffixes?c.suffixes:{};f=Number(g);m=0>f;b=2<d?1E3:1024;m&&(f=-f);0===f?e?b="0":(a="B",b="0"+k+(l[a]||a)):(a=Math.floor(Math.log(f)/Math.log(1E3)),8<a&&(a=8),d=2===d?f/Math.pow(2,10*a):f/Math.pow(1E3,a),h&&(d*=8,d>b&&(d/=b,a++)),b=d.toFixed(0<a?n:
0),a=q[h?"bits":"bytes"][a],e?(h&&r.test(a)&&(a=a.toLowerCase()),a=a.charAt(0),e=b.replace(s,""),"B"===a?a="":h||"k"!==a||(a="K"),t.test(e)&&(b=parseInt(b,u).toString()),b+=k+(l[a]||a)):e||(b+=k+(l[a]||a)));m&&(b="-"+b);return b}var r=/b$/,u=10,s=/.*\./,t=/^0$/,q={bits:"B kb Mb Gb Tb Pb Eb Zb Yb".split(" "),bytes:"B kB MB GB TB PB EB ZB YB".split(" ")};"undefined"!==typeof exports?module.exports=g:"function"===typeof define?define(function(){return g}):p.filesize=g})(this);
//@ sourceMappingURL=filesize.map