n3 3.0.0-alpha.5 → 3.0.0-alpha.7

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 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`.
@@ -487,6 +511,8 @@ The store implements the following manipulation methods in addition to the stand
487
511
  - `addQuads` to insert an array of quads
488
512
  - `removeQuad` to remove one quad
489
513
  - `removeQuads` to remove an array of quads
514
+ - `import` to insert a stream of quads; awaiting its result waits until the stream has ended
515
+ (start awaiting before the stream finishes for RDF/JS streams that are not Node.js streams)
490
516
  - `remove` to remove a stream of quads
491
517
  - `removeMatches` to remove all quads matching the given pattern
492
518
  - `deleteGraph` to remove all quads with the given graph