parse a string bytes <=> bytes
bytes is a sweet little util that helps in parsing a string bytes (ex: 1TB) to bytes (1099511627776) and vice-versa.
Get it: npm install --save bytes
Sample usage:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| bytes(1024);
// output: '1KB'
bytes(1000);
// output: '1000B'
bytes(1000, {thousandsSeparator: ' '});
// output: '1 000B'
bytes(1024 * 1.7, {decimalPlaces: 0});
// output: '2KB'
bytes(1024, {unitSeparator: ' '});
// output: '1 KB'
|
Supported units and abbreviations:
1
2
3
4
5
| b for bytes
kb for kilobytes
mb for megabytes
gb for gigabytes
tb for terabytes
|
GIF FTW!
