3 Utility to parse a string bytes (ex: `1TB`) to bytes (`1099511627776`) and vice-versa.
8 var bytes = require('bytes');
11 #### bytes.format(number value, [options]): string|null
13 Format the given value in bytes into a string. If the value is negative, it is kept as such. If it is a float, it is
18 | Name | Type | Description |
19 |---------|--------|--------------------|
20 | value | `number` | Value in bytes |
21 | options | `Object` | Conversion options |
25 | Property | Type | Description |
26 |-------------------|--------|-----------------------------------------------------------------------------------------|
27 | thousandsSeparator | `string`|`null` | Example of values: `' '`, `','` and `.`... Default value to `' '`. |
31 | Name | Type | Description |
32 |---------|-------------|-------------------------|
33 | results | `string`|`null` | Return null upon error. String value otherwise. |
44 bytes(1000, {thousandsSeparator: ' '});
48 #### bytes.parse(string value): number|null
50 Parse the string value into an integer in bytes. If no unit is given, it is assumed the value is in bytes.
54 | Name | Type | Description |
55 |---------------|--------|--------------------|
56 | value | `string` | String to parse. |
60 | Name | Type | Description |
61 |---------|-------------|-------------------------|
62 | results | `number`|`null` | Return null upon error. Value in bytes otherwise. |
77 npm install bytes --save
78 component install visionmedia/bytes.js
83 [![npm](https://img.shields.io/npm/l/express.svg)](https://github.com/visionmedia/bytes.js/blob/master/LICENSE)