readableBytes
Converts a number of bytes to a human readable file size.
Parameters
-
bytesnumber of bytes to show -
optionsObject? user provided options objectoptions.decimalsnumber? optional number of decimals to showoptions.minUnit("byte(s)"|"kB"|"MB"|"GB"|"TB"|"PB")? minimum unit to display; if undefined, the most appropriate unit is selected automatically
Examples
readableBytes(1234);
// => 1.205078125 kB
readableBytes(1234, { decimals: 2 });
// => 1.21 kB
readableBytes(500, { minUnit: 'kB' });
// => 0.48828125 kB
readableBytes(500, { decimals: 2, minUnit: 'kB' });
// => 0.49 kB kB
Returns string of human readable file size.
Meta
- version: 1.0.0
- Source: readable-bytes.ts