Comparing version 10.0.2 to 10.0.3
@@ -6,3 +6,3 @@ /** | ||
* @license BSD-3-Clause | ||
* @version 10.0.2 | ||
* @version 10.0.3 | ||
*/ | ||
@@ -193,3 +193,3 @@ const ARRAY = "array"; | ||
// Partial application for functional programming | ||
function partial ({ | ||
filesize.partial = function partial ({ | ||
bits = false, | ||
@@ -230,2 +230,2 @@ pad = false, | ||
}); | ||
}export{filesize,partial}; | ||
};export{filesize as default}; |
/*! | ||
2022 Jason Mulligan <jason.mulligan@avoidwork.com> | ||
@version 10.0.2 | ||
@version 10.0.3 | ||
*/ | ||
const t={symbol:{iec:{bits:["bit","Kibit","Mibit","Gibit","Tibit","Pibit","Eibit","Zibit","Yibit"],bytes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]},jedec:{bits:["bit","Kbit","Mbit","Gbit","Tbit","Pbit","Ebit","Zbit","Ybit"],bytes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]}},fullform:{iec:["","kibi","mebi","gibi","tebi","pebi","exbi","zebi","yobi"],jedec:["","kilo","mega","giga","tera","peta","exa","zetta","yotta"]}};function i(i,{bits:e=!1,pad:o=!1,base:n=-1,round:r=2,locale:b="",localeOptions:s={},separator:l="",spacer:a=" ",symbols:c={},standard:p="",output:u="string",fullform:d=!1,fullforms:f=[],exponent:g=-1,roundingMethod:m="round",precision:y=0}={}){let B=g,h=Number(i),M=[],j=0,x="";-1===n&&0===p.length?(n=10,p="jedec"):-1===n&&p.length>0?n="iec"===(p="iec"===p?"iec":"jedec")?2:10:p=10===(n=2===n?2:10)||"jedec"===p?"jedec":"iec";const w=10===n?1e3:1024,E=!0===d,N=h<0,T=Math[m];if("bigint"!=typeof i&&isNaN(i))throw new TypeError("Invalid number");if("function"!=typeof T)throw new TypeError("Invalid rounding method");if(N&&(h=-h),(-1===B||isNaN(B))&&(B=Math.floor(Math.log(h)/Math.log(w)),B<0&&(B=0)),B>8&&(y>0&&(y+=8-B),B=8),"exponent"===u)return B;if(0===h)M[0]=0,x=M[1]=t.symbol[p][e?"bits":"bytes"][B];else{j=h/(2===n?Math.pow(2,10*B):Math.pow(1e3,B)),e&&(j*=8,j>=w&&B<8&&(j/=w,B++));const i=Math.pow(10,B>0?r:0);M[0]=T(j*i)/i,M[0]===w&&B<8&&-1===g&&(M[0]=1,B++),x=M[1]=10===n&&1===B?e?"kbit":"kB":t.symbol[p][e?"bits":"bytes"][B]}if(N&&(M[0]=-M[0]),y>0&&(M[0]=M[0].toPrecision(y)),M[1]=c[M[1]]||M[1],!0===b?M[0]=M[0].toLocaleString():b.length>0?M[0]=M[0].toLocaleString(b,s):l.length>0&&(M[0]=M[0].toString().replace(".",l)),o&&!1===Number.isInteger(M[0])&&r>0){const t=l||".",i=M[0].toString().split(t),e=i[1]||"",o=e.length,n=r-o;M[0]=`${i[0]}${t}${e.padEnd(o+n,"0")}`}return E&&(M[1]=f[B]?f[B]:t.fullform[p][B]+(e?"bit":"byte")+(1===M[0]?"":"s")),"array"===u?M:"object"===u?{value:M[0],symbol:M[1],exponent:B,unit:x}:M.join(a)}function e({bits:t=!1,pad:e=!1,base:o=-1,round:n=2,locale:r="",localeOptions:b={},separator:s="",spacer:l=" ",symbols:a={},standard:c="",output:p="string",fullform:u=!1,fullforms:d=[],exponent:f=-1,roundingMethod:g="round",precision:m=0}={}){return y=>i(y,{bits:t,pad:e,base:o,round:n,locale:r,localeOptions:b,separator:s,spacer:l,symbols:a,standard:c,output:p,fullform:u,fullforms:d,exponent:f,roundingMethod:g,precision:m})}export{i as filesize,e as partial};//# sourceMappingURL=filesize.esm.min.js.map | ||
const t={symbol:{iec:{bits:["bit","Kibit","Mibit","Gibit","Tibit","Pibit","Eibit","Zibit","Yibit"],bytes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]},jedec:{bits:["bit","Kbit","Mbit","Gbit","Tbit","Pbit","Ebit","Zbit","Ybit"],bytes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]}},fullform:{iec:["","kibi","mebi","gibi","tebi","pebi","exbi","zebi","yobi"],jedec:["","kilo","mega","giga","tera","peta","exa","zetta","yotta"]}};function i(i,{bits:e=!1,pad:o=!1,base:n=-1,round:r=2,locale:a="",localeOptions:s={},separator:b="",spacer:l=" ",symbols:p={},standard:c="",output:u="string",fullform:d=!1,fullforms:f=[],exponent:g=-1,roundingMethod:m="round",precision:y=0}={}){let B=g,h=Number(i),M=[],j=0,x="";-1===n&&0===c.length?(n=10,c="jedec"):-1===n&&c.length>0?n="iec"===(c="iec"===c?"iec":"jedec")?2:10:c=10===(n=2===n?2:10)||"jedec"===c?"jedec":"iec";const w=10===n?1e3:1024,E=!0===d,N=h<0,T=Math[m];if("bigint"!=typeof i&&isNaN(i))throw new TypeError("Invalid number");if("function"!=typeof T)throw new TypeError("Invalid rounding method");if(N&&(h=-h),(-1===B||isNaN(B))&&(B=Math.floor(Math.log(h)/Math.log(w)),B<0&&(B=0)),B>8&&(y>0&&(y+=8-B),B=8),"exponent"===u)return B;if(0===h)M[0]=0,x=M[1]=t.symbol[c][e?"bits":"bytes"][B];else{j=h/(2===n?Math.pow(2,10*B):Math.pow(1e3,B)),e&&(j*=8,j>=w&&B<8&&(j/=w,B++));const i=Math.pow(10,B>0?r:0);M[0]=T(j*i)/i,M[0]===w&&B<8&&-1===g&&(M[0]=1,B++),x=M[1]=10===n&&1===B?e?"kbit":"kB":t.symbol[c][e?"bits":"bytes"][B]}if(N&&(M[0]=-M[0]),y>0&&(M[0]=M[0].toPrecision(y)),M[1]=p[M[1]]||M[1],!0===a?M[0]=M[0].toLocaleString():a.length>0?M[0]=M[0].toLocaleString(a,s):b.length>0&&(M[0]=M[0].toString().replace(".",b)),o&&!1===Number.isInteger(M[0])&&r>0){const t=b||".",i=M[0].toString().split(t),e=i[1]||"",o=e.length,n=r-o;M[0]=`${i[0]}${t}${e.padEnd(o+n,"0")}`}return E&&(M[1]=f[B]?f[B]:t.fullform[c][B]+(e?"bit":"byte")+(1===M[0]?"":"s")),"array"===u?M:"object"===u?{value:M[0],symbol:M[1],exponent:B,unit:x}:M.join(l)}i.partial=function({bits:t=!1,pad:e=!1,base:o=-1,round:n=2,locale:r="",localeOptions:a={},separator:s="",spacer:b=" ",symbols:l={},standard:p="",output:c="string",fullform:u=!1,fullforms:d=[],exponent:f=-1,roundingMethod:g="round",precision:m=0}={}){return y=>i(y,{bits:t,pad:e,base:o,round:n,locale:r,localeOptions:a,separator:s,spacer:b,symbols:l,standard:p,output:c,fullform:u,fullforms:d,exponent:f,roundingMethod:g,precision:m})};export{i as default};//# sourceMappingURL=filesize.esm.min.js.map |
@@ -6,5 +6,5 @@ /** | ||
* @license BSD-3-Clause | ||
* @version 10.0.2 | ||
* @version 10.0.3 | ||
*/ | ||
(function(g,f){typeof exports==='object'&&typeof module!=='undefined'?f(exports):typeof define==='function'&&define.amd?define(['exports'],f):(g=typeof globalThis!=='undefined'?globalThis:g||self,f(g.filesize={}));})(this,(function(exports){'use strict';const ARRAY = "array"; | ||
(function(g,f){typeof exports==='object'&&typeof module!=='undefined'?module.exports=f():typeof define==='function'&&define.amd?define(f):(g=typeof globalThis!=='undefined'?globalThis:g||self,g.filesize=f());})(this,(function(){'use strict';const ARRAY = "array"; | ||
const BIT = "bit"; | ||
@@ -193,3 +193,3 @@ const BITS = "bits"; | ||
// Partial application for functional programming | ||
function partial ({ | ||
filesize.partial = function partial ({ | ||
bits = false, | ||
@@ -230,2 +230,2 @@ pad = false, | ||
}); | ||
}exports.filesize=filesize;exports.partial=partial;Object.defineProperty(exports,'__esModule',{value:true});})); | ||
};return filesize;})); |
/*! | ||
2022 Jason Mulligan <jason.mulligan@avoidwork.com> | ||
@version 10.0.2 | ||
@version 10.0.3 | ||
*/ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).filesize={})}(this,(function(t){"use strict";const e="bits",i="bytes",o="",n="iec",r="jedec",l="round",s="string",a={symbol:{iec:{bits:["bit","Kibit","Mibit","Gibit","Tibit","Pibit","Eibit","Zibit","Yibit"],bytes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]},jedec:{bits:["bit","Kbit","Mbit","Gbit","Tbit","Pbit","Ebit","Zbit","Ybit"],bytes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]}},fullform:{iec:["","kibi","mebi","gibi","tebi","pebi","exbi","zebi","yobi"],jedec:["","kilo","mega","giga","tera","peta","exa","zetta","yotta"]}};function b(t,{bits:b=!1,pad:p=!1,base:f=-1,round:u=2,locale:d="",localeOptions:c={},separator:g="",spacer:m=" ",symbols:y={},standard:h="",output:B=s,fullform:M=!1,fullforms:x=[],exponent:T=-1,roundingMethod:j=l,precision:w=0}={}){let E=T,N=Number(t),P=[],k=0,v=o;-1===f&&0===h.length?(f=10,h=r):-1===f&&h.length>0?f=(h=h===n?n:r)===n?2:10:h=10===(f=2===f?2:10)||h===r?r:n;const z=10===f?1e3:1024,G=!0===M,K=N<0,O=Math[j];if("bigint"!=typeof t&&isNaN(t))throw new TypeError("Invalid number");if("function"!=typeof O)throw new TypeError("Invalid rounding method");if(K&&(N=-N),(-1===E||isNaN(E))&&(E=Math.floor(Math.log(N)/Math.log(z)),E<0&&(E=0)),E>8&&(w>0&&(w+=8-E),E=8),"exponent"===B)return E;if(0===N)P[0]=0,v=P[1]=a.symbol[h][b?e:i][E];else{k=N/(2===f?Math.pow(2,10*E):Math.pow(1e3,E)),b&&(k*=8,k>=z&&E<8&&(k/=z,E++));const t=Math.pow(10,E>0?u:0);P[0]=O(k*t)/t,P[0]===z&&E<8&&-1===T&&(P[0]=1,E++),v=P[1]=10===f&&1===E?b?"kbit":"kB":a.symbol[h][b?e:i][E]}if(K&&(P[0]=-P[0]),w>0&&(P[0]=P[0].toPrecision(w)),P[1]=y[P[1]]||P[1],!0===d?P[0]=P[0].toLocaleString():d.length>0?P[0]=P[0].toLocaleString(d,c):g.length>0&&(P[0]=P[0].toString().replace(".",g)),p&&!1===Number.isInteger(P[0])&&u>0){const t=g||".",e=P[0].toString().split(t),i=e[1]||o,n=i.length,r=u-n;P[0]=`${e[0]}${t}${i.padEnd(n+r,"0")}`}return G&&(P[1]=x[E]?x[E]:a.fullform[h][E]+(b?"bit":"byte")+(1===P[0]?o:"s")),"array"===B?P:"object"===B?{value:P[0],symbol:P[1],exponent:E,unit:v}:P.join(m)}t.filesize=b,t.partial=function({bits:t=!1,pad:e=!1,base:i=-1,round:o=2,locale:n="",localeOptions:r={},separator:a="",spacer:p=" ",symbols:f={},standard:u="",output:d=s,fullform:c=!1,fullforms:g=[],exponent:m=-1,roundingMethod:y=l,precision:h=0}={}){return l=>b(l,{bits:t,pad:e,base:i,round:o,locale:n,localeOptions:r,separator:a,spacer:p,symbols:f,standard:u,output:d,fullform:c,fullforms:g,exponent:m,roundingMethod:y,precision:h})},Object.defineProperty(t,"__esModule",{value:!0})}));//# sourceMappingURL=filesize.min.js.map | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).filesize=e()}(this,(function(){"use strict";const t="bits",e="bytes",i="",o="iec",n="jedec",r="round",l="string",s={symbol:{iec:{bits:["bit","Kibit","Mibit","Gibit","Tibit","Pibit","Eibit","Zibit","Yibit"],bytes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]},jedec:{bits:["bit","Kbit","Mbit","Gbit","Tbit","Pbit","Ebit","Zbit","Ybit"],bytes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]}},fullform:{iec:["","kibi","mebi","gibi","tebi","pebi","exbi","zebi","yobi"],jedec:["","kilo","mega","giga","tera","peta","exa","zetta","yotta"]}};function a(a,{bits:b=!1,pad:p=!1,base:u=-1,round:f=2,locale:d="",localeOptions:c={},separator:g="",spacer:m=" ",symbols:y={},standard:h="",output:B=l,fullform:M=!1,fullforms:x=[],exponent:T=-1,roundingMethod:w=r,precision:E=0}={}){let j=T,N=Number(a),P=[],k=0,G=i;-1===u&&0===h.length?(u=10,h=n):-1===u&&h.length>0?u=(h=h===o?o:n)===o?2:10:h=10===(u=2===u?2:10)||h===n?n:o;const K=10===u?1e3:1024,S=!0===M,Y=N<0,Z=Math[w];if("bigint"!=typeof a&&isNaN(a))throw new TypeError("Invalid number");if("function"!=typeof Z)throw new TypeError("Invalid rounding method");if(Y&&(N=-N),(-1===j||isNaN(j))&&(j=Math.floor(Math.log(N)/Math.log(K)),j<0&&(j=0)),j>8&&(E>0&&(E+=8-j),j=8),"exponent"===B)return j;if(0===N)P[0]=0,G=P[1]=s.symbol[h][b?t:e][j];else{k=N/(2===u?Math.pow(2,10*j):Math.pow(1e3,j)),b&&(k*=8,k>=K&&j<8&&(k/=K,j++));const i=Math.pow(10,j>0?f:0);P[0]=Z(k*i)/i,P[0]===K&&j<8&&-1===T&&(P[0]=1,j++),G=P[1]=10===u&&1===j?b?"kbit":"kB":s.symbol[h][b?t:e][j]}if(Y&&(P[0]=-P[0]),E>0&&(P[0]=P[0].toPrecision(E)),P[1]=y[P[1]]||P[1],!0===d?P[0]=P[0].toLocaleString():d.length>0?P[0]=P[0].toLocaleString(d,c):g.length>0&&(P[0]=P[0].toString().replace(".",g)),p&&!1===Number.isInteger(P[0])&&f>0){const t=g||".",e=P[0].toString().split(t),o=e[1]||i,n=o.length,r=f-n;P[0]=`${e[0]}${t}${o.padEnd(n+r,"0")}`}return S&&(P[1]=x[j]?x[j]:s.fullform[h][j]+(b?"bit":"byte")+(1===P[0]?i:"s")),"array"===B?P:"object"===B?{value:P[0],symbol:P[1],exponent:j,unit:G}:P.join(m)}return a.partial=function({bits:t=!1,pad:e=!1,base:i=-1,round:o=2,locale:n="",localeOptions:s={},separator:b="",spacer:p=" ",symbols:u={},standard:f="",output:d=l,fullform:c=!1,fullforms:g=[],exponent:m=-1,roundingMethod:y=r,precision:h=0}={}){return r=>a(r,{bits:t,pad:e,base:i,round:o,locale:n,localeOptions:s,separator:b,spacer:p,symbols:u,standard:f,output:d,fullform:c,fullforms:g,exponent:m,roundingMethod:y,precision:h})},a}));//# sourceMappingURL=filesize.min.js.map |
{ | ||
"name": "filesize", | ||
"description": "JavaScript library to generate a human readable String describing the file size", | ||
"version": "10.0.2", | ||
"version": "10.0.3", | ||
"homepage": "https://filesizejs.com", | ||
@@ -6,0 +6,0 @@ "author": "Jason Mulligan <jason.mulligan@avoidwork.com>", |
@@ -8,3 +8,3 @@ # filesize.js | ||
```javascript | ||
import {filesize} from "filesize"; | ||
import filesize from "filesize"; | ||
filesize(265318, {base: 2, standard: "jedec"}); // "259.1 KB" | ||
@@ -72,4 +72,4 @@ ``` | ||
```javascript | ||
import {partial} from "filesize"; | ||
const size = partial({base: 2, standard: "jedec"}); | ||
import filesize from "filesize"; | ||
const size = filesize.partial({base: 2, standard: "jedec"}); | ||
@@ -76,0 +76,0 @@ size(265318); // "259.1 KB" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
48503
727