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

Formatting to bits does not output thousands properly #84

Closed ussuritiger closed 7 years ago

ussuritiger commented 7 years ago

I am using the 3.4.2 version of package. I've got an issue while formatting bits. Please see the code and the output below.

filesize(124, {bits: true, base: 10}) // "992 b" filesize(125, {bits: true, base: 10}) // "1000 b" => I would expect "1 kb" filesize(126, {bits: true, base: 10}) // "1.01 kb"

Same goes for other thousands: filesize(125000, {bits: true, base: 10}) // "1000 kb" => I would expect "1 Mb" filesize(125000000, {bits: true, base: 10}) // "1000 Mb" => I would expect "1 Gb"

Hope it does not require much time to fix this. Thank you.

avoidwork commented 7 years ago

all this time, i thought no one used that flag. looks like it doesn't +1 when it should. i'll take a look.

ussuritiger commented 7 years ago

Apparently there are people who use this flag :) Moreover, it is hard to find a library that operates with bits. So this makes the library even greater. Keep up the good work and thanks for the quick response.