filesize.js is a simple browserjs / nodejs library to make filesize human-readable.
npm install filesize.js> filesize.js is a nano(350 b) library to make file size bytes human-readable. e.g. 20.4 Kb.




> npm install filesize.js
The unique API is: fileSize(bytes[, fixed=1, spec='jedec']);.
- bytes: Number of file size bytes.
- fixed: Number of decimal, default is 1.
- spec: String of file size spec, default is jedec.
``js
// bytes.
filesize(123456); // '120.6 Kb'
// fixed, 1 is default.
filesize(123456, 0); // '121 Kb'
filesize(123456, 4); // '1120.5625 Kb'
// specs, jedec / iec / si.jedec
// is default.`
filesize(123456, 2, 'iec'); // '120.56 Kib'
filesize(123456, 0, 'si'); // '123 kb'
> npm install
> npm test
- jedec: Unit is ['b', 'Kb', 'Mb', 'Gb', 'Tb', 'Pb', 'Eb', 'Zb', 'Yb'], and the power is 1024.['b', 'Kib', 'Mib', 'Gib', 'Tib', 'Pib', 'Eib', 'Zib', 'Yib']
- iec: Unit is , and the power is 1024.['b', 'kb', 'Mb', 'Gb', 'Tb', 'Pb', 'Eb', 'Zb', 'Yb']`, and the power is 1000.
- si: Unit is
More specs waiting for your issues / pull requests.
MIT@hustcc.