Skip to content

Commit

Permalink
Document prefix and context events
Browse files Browse the repository at this point in the history
  • Loading branch information
rubensworks committed Jul 8, 2022
1 parent e971663 commit 4bc1dda
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,26 @@ console.log(await rdfParser.getContentTypes());
console.log(await rdfParser.getContentTypesPrioritized());
```

### Obtaining prefixes

Using the `'prefix'` event, you can obtain the prefixes that were available when parsing from documents in formats such as Turtle and TriG.

```javascript
rdfParser.parse(textStream, { contentType: 'text/turtle' })
.on('prefix', (prefix, iri) => console.log(prefix + ':' + iri))
```

### Obtaining contexts

Using the `'context'` event, you can obtain all contexts (`@context`) when parsing JSON-LD documents.

Multiple contexts can be found, and the context values that are emitted correspond exactly to the context value as included in the JSON-LD document.

```javascript
rdfParser.parse(textStream, { contentType: 'application/ld+json' })
.on('context', (context) => console.log(context))
```

## License
This software is written by [Ruben Taelman](http://rubensworks.net/).

Expand Down

0 comments on commit 4bc1dda

Please sign in to comment.