avoidwork/filesize.js

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

rolandstarke opened this issue · 4 comments

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: #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>

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

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: #141, #150 (comment)
v2.0.0 to v8.0.7 supported it.

totally agree. 9.0.0 shifted it because #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.

This is 9.0.9.