Skip to content

Commit 67656e9

Browse files
committed
Update README.md
1 parent afcb04b commit 67656e9

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

README.md

+16-5
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,14 @@ const parser = new Parser({
1717
});
1818
```
1919

20-
#### Parsing
21-
Just pass object or buffer to `parse` method, and specify schema name and version:
20+
#### Simple parsing
21+
Just pass object or buffer to `parse` method, and specify schema name:
2222
```javascript
2323
const buffer = parser.parse(
2424
{
2525
...
2626
},
27-
'schemaName',
28-
'latest' // default
27+
'schemaName'
2928
);
3029

3130
const obj = parser.parse(buffer, 'schemaName');
@@ -62,11 +61,23 @@ NOTE: if field's size is greater than 4 bytes(more than Int32), it should be pas
6261

6362

6463
#### Versions
65-
You can easily update schemas without losing older ones. For version updating use semver contract:
64+
For schemas updating and versioning you can use `versions` extension for parser. It works like:
65+
```javascript
66+
const parser = new Parser(/* schemas */) // create a simple parser
67+
const versioned = parser.versions() // here will be created a new parser instance, supporting versioning
68+
// and old simple parser will not change after this
69+
```
70+
71+
Using `versions` extension you can easily update schemas without losing older ones. For version updating use semver contract:
6672
```javascript
6773
parser.updateSchema(
6874
schemaName,
6975
newSchema,
7076
updateType // 'major', 'minor' or 'patch'
7177
)
7278
```
79+
80+
You can also use any version of schema to parse data, just specify version as a last parameter of `parse` method, it is `latest` by default:
81+
```javascript
82+
parser.parse({ ... }, `schemaName`, `version`);
83+
```

0 commit comments

Comments
 (0)