Skip to content

Commit

Permalink
expose grammar as a public object to allow for custom grammar
Browse files Browse the repository at this point in the history
  • Loading branch information
reznikov committed Nov 15, 2024
1 parent b9cbb6b commit 7a6bf45
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,18 @@ sdpTransform.write(res).split('\r\n'); // res parsed above

The only thing different from the original input is we follow the order specified by the SDP RFC, and we will always do so.

## Usage - Custom grammar

In case you need to add custom grammar (e.g. add unofficial attributes) to the parser, you can do so by mutating the `grammar` object before parsing.

```js
sdpTransform.grammar['a'].push({
name: 'xCustomTag',
reg: /^x-custom-tag:(\d*)/,
names: ['tagId'],
format: 'x-custom:%d
})
```
## License
Expand Down
2 changes: 2 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
var parser = require('./parser');
var writer = require('./writer');
var grammar = require('./grammar');

exports.grammar = grammar;
exports.write = writer;
exports.parse = parser.parse;
exports.parseParams = parser.parseParams;
Expand Down

0 comments on commit 7a6bf45

Please sign in to comment.