Skip to content

Commit 10c21b2

Browse files
authored
Add README example on importing into a store
1 parent 5bee089 commit 10c21b2

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,23 @@ myParser.write(`}}`);
8181
myParser.end();
8282
```
8383

84+
### Convert a JSON-LD string to an RDF/JS dataset
85+
86+
```javascript
87+
import { Store } from 'n3';
88+
import { JsonLdParser } from 'jsonld-streaming-parser';
89+
import { promisifyEventEmitter } from 'event-emitter-promisify';
90+
91+
const store = new Store();
92+
const parser = new JsonLdParser();
93+
parser.write('{"@id": "http://example.org/jesse", "@type": "http://example.org/Thing"}');
94+
parser.end();
95+
await promisifyEventEmitter(store.import(parser));
96+
97+
// Logs all the quads in the store
98+
console.log(...store);
99+
```
100+
84101
### Import streams
85102

86103
This parser implements the RDFJS [Sink interface](https://rdf.js.org/#sink-interface),

0 commit comments

Comments
 (0)