@os-team/pretty-size
v1.2.1
Published
A tiny converter of number of bytes into a human-readable string. Support for all measures up to petabyte.
Readme
@os-team/pretty-size

A tiny converter of number of bytes into a human-readable string. Support for all measures up to petabyte.
Usage
Install the package using the following command:
yarn add @os-team/pretty-sizeConvert the file size as follows:
import prettySize from '@os-team/pretty-size';
const size = prettySize(1.123 * 10 ** 6); // 1.1 MBBy defualt, the precision is 1. You can set your own value as follows:
const size = prettySize(1.123 * 10 ** 3, {
precision: 2,
}); // 1.12 KBBy default, the base of the number is 10. You can set your own value as follows:
const size = prettySize(1.123 * 2 ** 10, {
base: 2,
}); // 1.1 KB