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

uncovered code #75

Closed starius closed 8 years ago

starius commented 8 years ago

The following case is not tested:

if (e > 8) {
    e = 8;
}
avoidwork commented 8 years ago

Don't care.

starius commented 8 years ago

It is not clear. What is the expected result of filesize(10e40)? Currently I get "82718061255302770 YB", but maybe "8.27e+16 YB" or even "1e+41 B" is better?

avoidwork commented 8 years ago

Why is that better? This module is approaching 4 million downloads on npm, and you're the first person to raise this concern. Could you explain it in further detail.

avoidwork commented 8 years ago

IMO, scientific notation doesn't equate to 'human readable', which why it's never output that. It could of course become a customizable output, and if you would like to see that I'd be willing to take your PR to introduce it.

starius commented 8 years ago

This module is approaching 4 million downloads on npm, and you're the first person to raise this concern.

There is a first time for everything :)

I noticed this while measuring coverage of my Lua version of this function. That line was the only uncovered line in the code. In Lua it becomes scientific notation and in JavaScript it is a plain integer representation.

IMO, scientific notation doesn't equate to 'human readable'

+1 for this. So "82718061255302770 YB" should be the expected output. I am going to open a pull request adding such test.