avoidwork / filesize.js

JavaScript library to generate a human readable String describing the file size
https://filesizejs.com
BSD 3-Clause "New" or "Revised" License
1.61k stars 97 forks source link

standard='iec' is not default anymore #148

Closed zerkms closed 2 years ago

zerkms commented 2 years ago

The check is defined as:

standard = base === 2 ? descriptor.standard || "iec" : "jedec";

Which reads - if only base equals 2 - take the descriptor.standard. But base default value is 10.

Hence

filesize(265318, { standard: 'iec' });              

would output "265.32 kB"

So it means:

  1. The readme is not entirely correct in its "(string) Standard unit of measure, can be iec or jedec, default is iec; can be overruled by base"
  2. standard option does nothing if base is not specified
avoidwork commented 2 years ago

yup, this is what people wanted for the last major release. i believe it was a mistake.

avoidwork commented 2 years ago

originally fixed with https://github.com/avoidwork/filesize.js/commit/bb72429202c4920c8a9133497b74c33eea86b60b and then undone with https://github.com/avoidwork/filesize.js/commit/afd78c28524d7a9e4830769385d2ade467991d90 which i have no idea atm; however i completely agree what it's configured to do right now is inane.