Bug:Fix file validation issue
[vnfsdk/refrepo.git] / vnfmarket / src / main / webapp / vnfmarket / node_modules / bytes / Readme.md
1 # Bytes utility
2
3 Utility to parse a string bytes (ex: `1TB`) to bytes (`1099511627776`) and vice-versa.
4
5 ## Usage
6
7 ```js
8 var bytes = require('bytes');
9 ```
10
11 #### bytes.format(number value, [options]): string|null
12
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
14  rounded.
15
16 **Arguments**
17
18 | Name    | Type   | Description        |
19 |---------|--------|--------------------|
20 | value   | `number` | Value in bytes     |
21 | options | `Object` | Conversion options |
22
23 **Options**
24
25 | Property          | Type   | Description                                                                             |
26 |-------------------|--------|-----------------------------------------------------------------------------------------|
27 | thousandsSeparator | `string`|`null` | Example of values: `' '`, `','` and `.`... Default value to `' '`. |
28
29 **Returns**
30
31 | Name    | Type        | Description             |
32 |---------|-------------|-------------------------|
33 | results | `string`|`null` | Return null upon error. String value otherwise. |
34
35 **Example**
36
37 ```js
38 bytes(1024);
39 // output: '1kB'
40
41 bytes(1000);
42 // output: '1000B'
43
44 bytes(1000, {thousandsSeparator: ' '});
45 // output: '1 000B'
46 ```
47
48 #### bytes.parse(string value): number|null
49
50 Parse the string value into an integer in bytes. If no unit is given, it is assumed the value is in bytes.
51
52 **Arguments**
53
54 | Name          | Type   | Description        |
55 |---------------|--------|--------------------|
56 | value   | `string` | String to parse.   |
57
58 **Returns**
59
60 | Name    | Type        | Description             |
61 |---------|-------------|-------------------------|
62 | results | `number`|`null` | Return null upon error. Value in bytes otherwise. |
63
64 **Example**
65
66 ```js
67 bytes('1kB');
68 // output: 1024
69
70 bytes('1024');
71 // output: 1024
72 ```
73
74 ## Installation
75
76 ```bash
77 npm install bytes --save
78 component install visionmedia/bytes.js
79 ```
80
81 ## License 
82
83 [![npm](https://img.shields.io/npm/l/express.svg)](https://github.com/visionmedia/bytes.js/blob/master/LICENSE)