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

filesize(1024); does not give "1.02 kB" #154

Closed rolandstarke closed 2 years ago

rolandstarke commented 2 years ago

The Readme has an example of:

filesize(1024);                       // "1.02 kB"

But the actual output is:

filesize(1024);                       // "1.02 kiB"

Would be cool if it worked like in the Readme. Also see: https://github.com/avoidwork/filesize.js/issues/150

For Anyone else you can use v8.0.7

<script src="https://unpkg.com/filesize@8.0.7/lib/filesize.min.js" defer></script>
avoidwork commented 2 years ago

It does work like the README.md says, the first option (base) has a default of 10. I've removed the outdated examples to remove confusion.

This is probably what you're looking for: https://github.com/avoidwork/filesize.js#partial-application

rolandstarke commented 2 years ago

Thanks for removing the confusion from the README.md.

I don't care about the default base change. I actually want base 10.

My only complaint is that there is an i in the unit, but i indicates base 2.

I am looking for using the SI prefix for base 10. See https://wiki.ubuntu.com/UnitsPolicy or https://en.m.wikipedia.org/wiki/Byte#Multiple-byte_units Releates: https://github.com/avoidwork/filesize.js/issues/141, https://github.com/avoidwork/filesize.js/issues/150#issuecomment-1153093374 v2.0.0 to v8.0.7 supported it.

avoidwork commented 2 years ago

totally agree. 9.0.0 shifted it because https://github.com/avoidwork/filesize.js/issues/152 is the cause of the regression.

there's 2 camps which do not agree on how it works. I'll return the original behavior.

avoidwork commented 2 years ago

This is 9.0.9.