blob: 9bcf73a39a3e09d7f002b9eb5cd5decc9f7dfc6b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# pretty-bytes [](https://travis-ci.org/sindresorhus/pretty-bytes)
> Convert bytes to a human readable string: `1337` → `1.34 kB`
Useful for displaying file sizes for humans.
-
*Note that it uses base-10 (e.g. kilobyte).
[Read about the difference between kilobyte and kibibyte.](http://pacoup.com/2009/05/26/kb-kb-kib-whats-up-with-that/)*
## Install
```
$ npm install --save pretty-bytes
```
## Usage
```js
const prettyBytes = require('pretty-bytes');
prettyBytes(1337);
//=> '1.34 kB'
prettyBytes(100);
//=> '100 B'
```
## Related
- [pretty-bytes-cli](https://github.com/sindresorhus/pretty-bytes-cli) - CLI for this module
## License
MIT © [Sindre Sorhus](https://sindresorhus.com)
|