|
1 | 1 | [](http://travis-ci.org/avoidwork/filesize.js)
|
2 | 2 | # filesize.js
|
3 | 3 |
|
4 |
| -filesize.js provides a simple way to get a human readable file size string from a number (float or integer) or string. An optional second parameter is the decimal place to round to (default is 2), or _true_ which triggers Unix style output. An optional third parameter lets you disable `bit` sizes, e.g. "Kb". |
| 4 | +filesize.js provides a simple way to get a human readable file size string from a number (float or integer) or string. An optional second parameter is the decimal place to round to (default is 2), or _true_ which triggers Unix style output. An optional third parameter lets you disable `bit` sizes, e.g. "kb". |
5 | 5 |
|
6 | 6 | ## Examples
|
7 | 7 |
|
| 8 | +0.10.0 switched to base 10, all previous versions use base 2. |
| 9 | + |
8 | 10 | ```javascript
|
9 |
| -filesize(500); // "3.91 Kb" |
10 |
| -filesize(500, true); // "3.9k" |
11 |
| -filesize(1500); // "1.46 KB" |
12 |
| -filesize("1500000000"); // "1.40 GB" |
13 |
| -filesize("1500000000", 0); // "1 GB" |
14 |
| -filesize(1212312421412412); // "1.08 PB" |
| 11 | +filesize(500); // "4.00 Kb" |
| 12 | +filesize(500, true); // "4.0k" |
| 13 | +filesize(1500); // "1.50 KB" |
| 14 | +filesize("1500000000"); // "1.50 GB" |
| 15 | +filesize("1500000000", 0); // "2GB" |
| 16 | +filesize(1212312421412412); // "1.21 PB PB" |
15 | 17 | filesize(1212312421412412, true); // "1.1P" - shorthand output, similar to "ls -h"
|
16 |
| -filesize(265318, 2, false) // "259.10 KB" - disabled `bit` sizes with third argument |
| 18 | +filesize(265318, 2, false) // "265.32 kB" - disabled `bit` sizes with third argument |
17 | 19 | ```
|
18 | 20 |
|
19 | 21 | ## How can I load filesize.js?
|
|
0 commit comments