n3 3.0.0-alpha.4 → 3.0.0-alpha.5

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
@@ -158,6 +158,20 @@ const quads = parser.parse('<a> <b> "hello"@en.', {
158
158
  });
159
159
  ```
160
160
 
161
+ Packages that extend a format with their own directives can register their names with the `directives` option.
162
+ Between statements (outside graph blocks and formulas), a registered directive is accepted
163
+ as `@name .` in Turtle, TriG and N3, and as `NAME` (case-insensitive) in all formats, including N-Triples and N-Quads.
164
+ `onDirective(name)` receives each one in order with the quads, and `N3.StreamParser` emits them as `directive` events.
165
+ Names consist of letters only, and cannot be words that already have a meaning in the grammar, such as `prefix` or `a`.
166
+
167
+ ```JavaScript
168
+ const parser = new N3.Parser({ format: 'N-Quads', directives: ['message'] });
169
+ parser.parse('<a> <b> <c> .\nMESSAGE\n<a> <b> <d> .\n', {
170
+ onQuad: (error, quad) => { /* … */ },
171
+ onDirective: name => { console.log('end of a message'); },
172
+ });
173
+ ```
174
+
161
175
  If no callbacks are provided, parsing happens synchronously returning an array of quads:
162
176
 
163
177
  ```JavaScript
@@ -234,6 +248,13 @@ of also rescoping blank node labels in lists and blank node property lists:
234
248
  const parser = new N3.Parser({ format: 'N3', formulaScopedBlankNodes: false });
235
249
  ```
236
250
 
251
+ The parser rejects triple terms nested more than 1024 levels deep,
252
+ so that the resulting quads stay within what the store and writer can traverse.
253
+ The `maxTripleTermDepth` option changes this limit (`Infinity` removes it):
254
+ ```JavaScript
255
+ const parser = new N3.Parser({ maxTripleTermDepth: 64 });
256
+ ```
257
+
237
258
  ### From an RDF stream to quads
238
259
 
239
260
  `N3.Parser` can parse [Node.js streams](http://nodejs.org/api/stream.html) as they grow,
@@ -566,6 +587,17 @@ Both budgets are unbounded by default;
566
587
  `reason()` throws when one is exceeded,
567
588
  leaving any quads derived up to that point in the store.
568
589
 
590
+ ## Extensions
591
+ The following packages build on N3.js to support formats or features beyond the W3C specifications listed under [Compatibility](#compatibility).
592
+ They are maintained separately from N3.js; please report issues with them in their own repositories.
593
+
594
+ | Package | Description |
595
+ | ------- | ----------- |
596
+ | [n3.js-messages](https://www.npmjs.com/package/n3.js-messages) | Parses and writes [RDF Messages](https://w3c-cg.github.io/rsp/spec/messages) (message-delimited Turtle, TriG, N-Triples and N-Quads). |
597
+ | [@jeswr/n3-provenance](https://github.com/jeswr/n3-provenance) | Experimental. Maps the terms of parsed quads back to their source positions in the input document. Terms that the parser generates, such as list nodes and reification scaffolding, have no position. It builds on the parser's `onToken` and `onTokenEnd` callbacks, but also subclasses private parser and index internals, so it is pinned to a specific N3.js revision. |
598
+
599
+ To list a package here, open a pull request that adds a row to this table.
600
+
569
601
  ## Compatibility
570
602
  ### Format specifications
571
603
  The N3.js parser and writer is fully compatible with the following W3C specifications: