Standard property does not switch base
zerkms opened this issue · 3 comments
zerkms commented
console.log(filesize(265318, {standard: "jedec"}), filesize(265318, {standard: "iec"})) // 265.32 KB 265.32 KiBRelated: #148
avoidwork commented
This is 9.0.6
avoidwork commented
This is a regression and undone with 9.0.9. the standards do not dictate the base, because they are both base 2. The decimal prefix delta of binary (JEDEC) is only the lower case 'k' on kilo.
avoidwork commented
To clarify: the base does dictate the standard; base 10 is JEDEC (unless overridden) with a tiny string op for the 'k' as per 2.x.x - 8.x.x.
I restructured the conditional statements to make it clearer:
// Sync base & standard
if (base === -1 && standard.length === 0) {
base = 10;
standard = JEDEC;
} else if (base === -1 && standard.length > 0) {
standard = standard === IEC ? IEC : JEDEC;
base = standard === IEC ? 2 : 10;
} else {
base = base === 2 ? 2 : 10;
standard = base === 10 ? JEDEC : IEC;
}