Skip to content

Commit 35aedfd

Browse files
committed
Fixing assignment of base and returning original behavior, fixing base2 tests
1 parent 1724dd8 commit 35aedfd

11 files changed

+73
-36
lines changed

lib/filesize.es6.js

+11-2
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,24 @@
3636
* @param {Object} descriptor [Optional] Flags
3737
* @return {String} Readable file size String
3838
*/
39-
function filesize (arg, {bits = false, pad = false, base = 10, round = 2, locale = "", localeOptions = {}, separator = "", spacer = " ", symbols = {}, standard = "iec", output = "string", fullform = false, fullforms = [], exponent = -1, roundingMethod = "round", precision = 0} = {}) {
39+
function filesize (arg, {bits = false, pad = false, base = -1, round = 2, locale = "", localeOptions = {}, separator = "", spacer = " ", symbols = {}, standard = "", output = "string", fullform = false, fullforms = [], exponent = -1, roundingMethod = "round", precision = 0} = {}) {
4040
let e = exponent,
4141
num = Number(arg),
4242
result = [],
4343
val = 0,
4444
u = "";
4545

4646
// Sync base & standard
47-
base = standard === "iec" ? 10 : 2;
47+
if (base === -1 && standard.length === 0) {
48+
base = 10;
49+
standard = "iec";
50+
} else if (base === -1 && standard.length > 0) {
51+
standard = standard === "iec" ? "iec" : "jedec";
52+
base = standard === "iec" ? 10 : 2;
53+
} else {
54+
base = base === 2 ? 2 : 10;
55+
standard = base === 10 ? "iec" : "jedec";
56+
}
4857

4958
const ceil = base === 10 ? 1000 : 1024,
5059
full = fullform === true,

lib/filesize.es6.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)