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

exponent option won't take effect when filesize is 0 #85

Closed croogie closed 7 years ago

croogie commented 7 years ago

Let's consider scenario:

> filesize(100000000, { exponent: 2 })
'95.37 MB'
> filesize(0, { exponent: 2 })
'0 B'

In second call you can see that even if exponent option has been passed a result is returned in bytes.

avoidwork commented 7 years ago

0 is currently a short circuit; fixing this is trivial 👍