filesize
Advanced tools
Comparing version 4.0.0 to 4.1.1
@@ -6,3 +6,3 @@ /** | ||
* @license BSD-3-Clause | ||
* @version 4.0.0 | ||
* @version 4.1.1 | ||
*/ | ||
@@ -37,3 +37,3 @@ (function (global) { | ||
val = 0, | ||
e, base, bits, ceil, full, fullforms, neg, num, output, round, unix, separator, spacer, standard, symbols; | ||
e, base, bits, ceil, full, fullforms, locale, neg, num, output, round, unix, separator, spacer, standard, symbols; | ||
@@ -48,3 +48,4 @@ if (isNaN(arg)) { | ||
round = descriptor.round !== void 0 ? descriptor.round : unix ? 1 : 2; | ||
separator = descriptor.separator !== void 0 ? descriptor.separator || "" : ""; | ||
locale = descriptor.locale !== void 0 ? descriptor.locale : ""; | ||
separator = descriptor.separator !== void 0 ? descriptor.separator : ""; | ||
spacer = descriptor.spacer !== void 0 ? descriptor.spacer : unix ? "" : " "; | ||
@@ -126,6 +127,2 @@ symbols = descriptor.symbols || {}; | ||
if (output === "object") { | ||
return {value: result[0], symbol: result[1]}; | ||
} | ||
if (full) { | ||
@@ -135,6 +132,12 @@ result[1] = fullforms[e] ? fullforms[e] : fullform[standard][e] + (bits ? "bit" : "byte") + (result[0] === 1 ? "" : "s"); | ||
if (separator.length > 0) { | ||
if (locale.length > 0) { | ||
result[0] = result[0].toLocaleString(locale); | ||
} else if (separator.length > 0) { | ||
result[0] = result[0].toString().replace(".", separator); | ||
} | ||
if (output === "object") { | ||
return {value: result[0], symbol: result[1]}; | ||
} | ||
return result.join(spacer); | ||
@@ -141,0 +144,0 @@ } |
@@ -8,3 +8,3 @@ "use strict"; | ||
* @license BSD-3-Clause | ||
* @version 4.0.0 | ||
* @version 4.1.1 | ||
*/ | ||
@@ -47,2 +47,3 @@ (function (global) { | ||
fullforms = void 0, | ||
locale = void 0, | ||
neg = void 0, | ||
@@ -66,3 +67,4 @@ num = void 0, | ||
round = descriptor.round !== void 0 ? descriptor.round : unix ? 1 : 2; | ||
separator = descriptor.separator !== void 0 ? descriptor.separator || "" : ""; | ||
locale = descriptor.locale !== void 0 ? descriptor.locale : ""; | ||
separator = descriptor.separator !== void 0 ? descriptor.separator : ""; | ||
spacer = descriptor.spacer !== void 0 ? descriptor.spacer : unix ? "" : " "; | ||
@@ -144,6 +146,2 @@ symbols = descriptor.symbols || {}; | ||
if (output === "object") { | ||
return { value: result[0], symbol: result[1] }; | ||
} | ||
if (full) { | ||
@@ -153,6 +151,12 @@ result[1] = fullforms[e] ? fullforms[e] : fullform[standard][e] + (bits ? "bit" : "byte") + (result[0] === 1 ? "" : "s"); | ||
if (separator.length > 0) { | ||
if (locale.length > 0) { | ||
result[0] = result[0].toLocaleString(locale); | ||
} else if (separator.length > 0) { | ||
result[0] = result[0].toString().replace(".", separator); | ||
} | ||
if (output === "object") { | ||
return { value: result[0], symbol: result[1] }; | ||
} | ||
return result.join(spacer); | ||
@@ -159,0 +163,0 @@ } |
{ | ||
"name": "filesize", | ||
"description": "JavaScript library to generate a human readable String describing the file size", | ||
"version": "4.0.0", | ||
"version": "4.1.1", | ||
"homepage": "https://filesizejs.com", | ||
@@ -6,0 +6,0 @@ "author": "Jason Mulligan <jason.mulligan@avoidwork.com>", |
@@ -26,2 +26,5 @@ # filesize.js | ||
### locale (overrides 'separator') | ||
_*(string)*_ BCP 47 language tag, default is `""` | ||
### output | ||
@@ -66,2 +69,3 @@ _*(string)*_ Output of function (`array`, `exponent`, `object`, or `string`), default is `string` | ||
filesize(265318, {separator: ","}); // "259,1 KB" | ||
filesize(265318, {locale: "de"}); // "259,1 KB" | ||
``` | ||
@@ -68,0 +72,0 @@ |
15074
281
90