n3 1.15.0 → 1.16.2

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
@@ -282,23 +282,40 @@ Then, we find triples with `:Mickey` as subject.
282
282
 
283
283
  ```JavaScript
284
284
  const store = new N3.Store();
285
- store.addQuad(
285
+ store.add(
286
286
  namedNode('http://ex.org/Pluto'),
287
287
  namedNode('http://ex.org/type'),
288
288
  namedNode('http://ex.org/Dog')
289
289
  );
290
- store.addQuad(
290
+ store.add(
291
291
  namedNode('http://ex.org/Mickey'),
292
292
  namedNode('http://ex.org/type'),
293
293
  namedNode('http://ex.org/Mouse')
294
294
  );
295
295
 
296
- const mickey = store.getQuads(namedNode('http://ex.org/Mickey'), null, null)[0];
297
- console.log(mickey);
296
+ // Retrieve all quads
297
+ for (const quad of store)
298
+ console.log(quad);
299
+ // Retrieve Mickey's quads
300
+ for (const quad of store.match(namedNode('http://ex.org/Mickey'), null, null))
301
+ console.log(quad);
298
302
  ```
299
303
 
304
+ ### [`DatasetCore` Interface](https://rdf.js.org/dataset-spec/#datasetcore-interface)
305
+ This store adheres to the `DatasetCore` interface which exposes the following properties
306
+
307
+ Attributes:
308
+ - `size` — A non-negative integer that specifies the number of quads in the set.
309
+
310
+ Methods:
311
+ - `add` — Adds the specified quad to the dataset. Existing quads, as defined in `Quad.equals`, will be ignored.
312
+ - `delete` — Removes the specified quad from the dataset.
313
+ - `has` — Determines whether a dataset includes a certain quad.
314
+ - `match` — Returns a new dataset that is comprised of all quads in the current instance matching the given arguments.
315
+ - `[Symbol.iterator]` — Implements the iterator protocol to allow iteration over all `quads` in the dataset as in the example above.
316
+
300
317
  ### Addition and deletion of quads
301
- The store provides the following manipulation methods
318
+ The store provides the following manipulation methods in addition to implementing the standard [`DatasetCore` Interface](https://rdf.js.org/dataset-spec/#datasetcore-interface)
302
319
  ([documentation](http://rdfjs.github.io/N3.js/docs/N3Store.html)):
303
320
  - `addQuad` to insert one quad
304
321
  - `addQuads` to insert an array of quads
@@ -312,6 +329,7 @@ The store provides the following manipulation methods
312
329
  ### Searching quads or entities
313
330
  The store provides the following search methods
314
331
  ([documentation](http://rdfjs.github.io/N3.js/docs/N3Store.html)):
332
+ - `readQuads` returns a generator of quads matching the given pattern
315
333
  - `getQuads` returns an array of quads matching the given pattern
316
334
  - `match` returns a stream of quads matching the given pattern
317
335
  - `countQuads` counts the number of quads matching the given pattern
@@ -381,6 +399,7 @@ The N3.js submodules are compatible with the following [RDF.js](http://rdf.js.or
381
399
  [`Store`](http://rdf.js.org/stream-spec/#store-interface)
382
400
  [`Source`](http://rdf.js.org/stream-spec/#source-interface)
383
401
  [`Sink`](http://rdf.js.org/stream-spec/#sink-interface)
402
+ [`DatasetCore`](https://rdf.js.org/dataset-spec/#datasetcore-interface)
384
403
 
385
404
  ## License and contributions
386
405
  The N3.js library is copyrighted by [Ruben Verborgh](https://ruben.verborgh.org/)