n3 3.0.0-alpha.5 → 3.0.0-alpha.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -0
- package/browser/n3.esm.min.js +12 -13
- package/browser/n3.min.js +12 -13
- package/lib/N3Lexer.js +54 -14
- package/lib/N3Parser.js +16 -5
- package/lib/N3Store.js +4 -1
- package/lib/N3Writer.js +20 -8
- package/package.json +1 -1
- package/src/N3Lexer.js +46 -14
- package/src/N3Parser.js +20 -5
- package/src/N3Store.js +4 -1
- package/src/N3Writer.js +23 -8
package/README.md
CHANGED
|
@@ -356,6 +356,30 @@ A `baseIRI` argument makes the writer abbreviate IRIs relative to that base in T
|
|
|
356
356
|
const writer = new N3.Writer({ baseIRI: 'http://example.org/', writeBase: false });
|
|
357
357
|
```
|
|
358
358
|
|
|
359
|
+
A `version` argument writes an RDF 1.2 version directive at the top of the document,
|
|
360
|
+
as `@version "1.2".` in Turtle/TriG or `VERSION "1.2"` in N-Triples/N-Quads.
|
|
361
|
+
The constructor throws for a label that contains quotes, backslashes, control characters, or unpaired surrogates.
|
|
362
|
+
|
|
363
|
+
```JavaScript
|
|
364
|
+
const writer = new N3.Writer({ version: '1.2' });
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
Packages that add their own syntax can extend `N3.Writer`.
|
|
368
|
+
`this._endStatement()` finishes the pending statement (and closes an open graph block),
|
|
369
|
+
`this._write(text, done)` writes text to the output,
|
|
370
|
+
and `this._lineMode` tells whether the output is N-Triples or N-Quads.
|
|
371
|
+
|
|
372
|
+
```JavaScript
|
|
373
|
+
class GroupWriter extends N3.Writer {
|
|
374
|
+
addGroup(quads, done) {
|
|
375
|
+
for (const quad of quads)
|
|
376
|
+
this.addQuad(quad);
|
|
377
|
+
this._endStatement();
|
|
378
|
+
this._write(this._lineMode ? 'GROUP\n' : '@group .\n', done);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
```
|
|
382
|
+
|
|
359
383
|
### From quads to an RDF stream
|
|
360
384
|
|
|
361
385
|
`N3.Writer` can also write quads to a Node.js stream through `addQuad`.
|