n3 1.17.4 → 1.17.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.
@@ -9,7 +9,7 @@ exports.termFromId = termFromId;
9
9
  exports.termToId = termToId;
10
10
  exports.unescapeQuotes = unescapeQuotes;
11
11
  var _IRIs = _interopRequireDefault(require("./IRIs"));
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
13
  // N3.js implementations of the RDF/JS core data types
14
14
  // See https://github.com/rdfjs/representation-task-force/blob/master/interface-spec.md
15
15
 
package/lib/N3Lexer.js CHANGED
@@ -7,7 +7,7 @@ exports.default = void 0;
7
7
  var _buffer = require("buffer");
8
8
  var _queueMicrotask = _interopRequireDefault(require("queue-microtask"));
9
9
  var _IRIs = _interopRequireDefault(require("./IRIs"));
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
11
  // **N3Lexer** tokenizes N3 documents.
12
12
 
13
13
  const {
package/lib/N3Parser.js CHANGED
@@ -7,7 +7,7 @@ exports.default = void 0;
7
7
  var _N3Lexer = _interopRequireDefault(require("./N3Lexer"));
8
8
  var _N3DataFactory = _interopRequireDefault(require("./N3DataFactory"));
9
9
  var _IRIs = _interopRequireDefault(require("./IRIs"));
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
11
  // **N3Parser** parses N3 documents.
12
12
 
13
13
  let blankNodePrefix = 0;
@@ -232,7 +232,7 @@ class N3Parser {
232
232
  } else this._subject = this._literal(token.value, this._namedNode(token.prefix));
233
233
  break;
234
234
  case '<<':
235
- if (!this._supportsRDFStar) return this._error('Unexpected RDF* syntax', token);
235
+ if (!this._supportsRDFStar) return this._error('Unexpected RDF-star syntax', token);
236
236
  this._saveContext('<<', this._graph, null, null, null);
237
237
  this._graph = null;
238
238
  return this._readSubject;
@@ -309,7 +309,7 @@ class N3Parser {
309
309
  this._saveContext('formula', this._graph, this._subject, this._predicate, this._graph = this._blankNode());
310
310
  return this._readSubject;
311
311
  case '<<':
312
- if (!this._supportsRDFStar) return this._error('Unexpected RDF* syntax', token);
312
+ if (!this._supportsRDFStar) return this._error('Unexpected RDF-star syntax', token);
313
313
  this._saveContext('<<', this._graph, this._subject, this._predicate, null);
314
314
  this._graph = null;
315
315
  return this._readSubject;
@@ -574,7 +574,7 @@ class N3Parser {
574
574
  break;
575
575
  // {| means that the current triple is annotated with predicate-object pairs.
576
576
  case '{|':
577
- if (!this._supportsRDFStar) return this._error('Unexpected RDF* syntax', token);
577
+ if (!this._supportsRDFStar) return this._error('Unexpected RDF-star syntax', token);
578
578
  // Continue using the last triple as quoted triple subject for the predicate-object pairs.
579
579
  const predicate = this._predicate,
580
580
  object = this._object;
@@ -789,7 +789,7 @@ class N3Parser {
789
789
  return this._readPath;
790
790
  }
791
791
 
792
- // ### `_readRDFStarTailOrGraph` reads the graph of a nested RDF* quad or the end of a nested RDF* triple
792
+ // ### `_readRDFStarTailOrGraph` reads the graph of a nested RDF-star quad or the end of a nested RDF-star triple
793
793
  _readRDFStarTailOrGraph(token) {
794
794
  if (token.type !== '>>') {
795
795
  // An entity means this is a quad (only allowed if not already inside a graph)
@@ -799,7 +799,7 @@ class N3Parser {
799
799
  return this._readRDFStarTail(token);
800
800
  }
801
801
 
802
- // ### `_readRDFStarTail` reads the end of a nested RDF* triple
802
+ // ### `_readRDFStarTail` reads the end of a nested RDF-star triple
803
803
  _readRDFStarTail(token) {
804
804
  if (token.type !== '>>') return this._error(`Expected >> but got ${token.type}`, token);
805
805
  // Read the quad and restore the previous context
package/lib/N3Store.js CHANGED
@@ -3,47 +3,41 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
6
+ exports.default = exports.N3EntityIndex = void 0;
7
7
  var _readableStream = require("readable-stream");
8
8
  var _N3DataFactory = _interopRequireWildcard(require("./N3DataFactory"));
9
9
  var _IRIs = _interopRequireDefault(require("./IRIs"));
10
10
  var _N3Util = require("./N3Util");
11
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
12
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
13
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
13
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
14
14
  // **N3Store** objects store N3 quads by graph in memory.
15
15
 
16
+ const ITERATOR = Symbol('iter');
17
+
16
18
  // ## Constructor
17
- class N3Store {
18
- constructor(quads, options) {
19
- // The number of quads is initially zero
20
- this._size = 0;
21
- // `_graphs` contains subject, predicate, and object indexes per graph
22
- this._graphs = Object.create(null);
19
+ class N3EntityIndex {
20
+ constructor(options = {}) {
21
+ this._id = 1;
23
22
  // `_ids` maps entities such as `http://xmlns.com/foaf/0.1/name` to numbers,
24
23
  // saving memory by using only numbers as keys in `_graphs`
25
- this._id = 0;
26
24
  this._ids = Object.create(null);
27
- this._entities = Object.create(null); // inverse of `_ids`
25
+ this._ids[''] = 1;
26
+ // inverse of `_ids`
27
+ this._entities = Object.create(null);
28
+ this._entities[1] = '';
28
29
  // `_blankNodeIndex` is the index of the last automatically named blank node
29
30
  this._blankNodeIndex = 0;
30
-
31
- // Shift parameters if `quads` is not given
32
- if (!options && quads && !quads[0]) options = quads, quads = null;
33
- options = options || {};
34
31
  this._factory = options.factory || _N3DataFactory.default;
35
-
36
- // Add quads if passed
37
- if (quads) this.addQuads(quads);
38
32
  }
39
- _termFromId(id, factory) {
33
+ _termFromId(id) {
40
34
  if (id[0] === '.') {
41
35
  const entities = this._entities;
42
36
  const terms = id.split('.');
43
37
  const q = this._factory.quad(this._termFromId(entities[terms[1]]), this._termFromId(entities[terms[2]]), this._termFromId(entities[terms[3]]), terms[4] && this._termFromId(entities[terms[4]]));
44
38
  return q;
45
39
  }
46
- return (0, _N3DataFactory.termFromId)(id, factory);
40
+ return (0, _N3DataFactory.termFromId)(id, this._factory);
47
41
  }
48
42
  _termToNumericId(term) {
49
43
  if (term.termType === 'Quad') {
@@ -60,6 +54,50 @@ class N3Store {
60
54
  const str = term && term.termType === 'Quad' ? `.${this._termToNewNumericId(term.subject)}.${this._termToNewNumericId(term.predicate)}.${this._termToNewNumericId(term.object)}${(0, _N3Util.isDefaultGraph)(term.graph) ? '' : `.${this._termToNewNumericId(term.graph)}`}` : (0, _N3DataFactory.termToId)(term);
61
55
  return this._ids[str] || (this._ids[this._entities[++this._id] = str] = this._id);
62
56
  }
57
+ createBlankNode(suggestedName) {
58
+ let name, index;
59
+ // Generate a name based on the suggested name
60
+ if (suggestedName) {
61
+ name = suggestedName = `_:${suggestedName}`, index = 1;
62
+ while (this._ids[name]) name = suggestedName + index++;
63
+ }
64
+ // Generate a generic blank node name
65
+ else {
66
+ do {
67
+ name = `_:b${this._blankNodeIndex++}`;
68
+ } while (this._ids[name]);
69
+ }
70
+ // Add the blank node to the entities, avoiding the generation of duplicates
71
+ this._ids[name] = ++this._id;
72
+ this._entities[this._id] = name;
73
+ return this._factory.blankNode(name.substr(2));
74
+ }
75
+ }
76
+
77
+ // ## Constructor
78
+ exports.N3EntityIndex = N3EntityIndex;
79
+ class N3Store {
80
+ constructor(quads, options) {
81
+ // The number of quads is initially zero
82
+ this._size = 0;
83
+ // `_graphs` contains subject, predicate, and object indexes per graph
84
+ this._graphs = Object.create(null);
85
+
86
+ // Shift parameters if `quads` is not given
87
+ if (!options && quads && !quads[0]) options = quads, quads = null;
88
+ options = options || {};
89
+ this._factory = options.factory || _N3DataFactory.default;
90
+ this._entityIndex = options.entityIndex || new N3EntityIndex({
91
+ factory: this._factory
92
+ });
93
+ this._entities = this._entityIndex._entities;
94
+ this._termFromId = this._entityIndex._termFromId.bind(this._entityIndex);
95
+ this._termToNumericId = this._entityIndex._termToNumericId.bind(this._entityIndex);
96
+ this._termToNewNumericId = this._entityIndex._termToNewNumericId.bind(this._entityIndex);
97
+
98
+ // Add quads if passed
99
+ if (quads) this.addQuads(quads);
100
+ }
63
101
 
64
102
  // ## Public properties
65
103
 
@@ -115,7 +153,7 @@ class N3Store {
115
153
  *_findInIndex(index0, key0, key1, key2, name0, name1, name2, graphId) {
116
154
  let tmp, index1, index2;
117
155
  const entityKeys = this._entities;
118
- const graph = this._termFromId(graphId, this._factory);
156
+ const graph = this._termFromId(entityKeys[graphId]);
119
157
  const parts = {
120
158
  subject: null,
121
159
  predicate: null,
@@ -126,17 +164,17 @@ class N3Store {
126
164
  if (key0) (tmp = index0, index0 = {})[key0] = tmp[key0];
127
165
  for (const value0 in index0) {
128
166
  if (index1 = index0[value0]) {
129
- parts[name0] = this._termFromId(entityKeys[value0], this._factory);
167
+ parts[name0] = this._termFromId(entityKeys[value0]);
130
168
  // If a key is specified, use only that part of index 1.
131
169
  if (key1) (tmp = index1, index1 = {})[key1] = tmp[key1];
132
170
  for (const value1 in index1) {
133
171
  if (index2 = index1[value1]) {
134
- parts[name1] = this._termFromId(entityKeys[value1], this._factory);
172
+ parts[name1] = this._termFromId(entityKeys[value1]);
135
173
  // If a key is specified, use only that part of index 2, if it exists.
136
174
  const values = key2 ? key2 in index2 ? [key2] : [] : Object.keys(index2);
137
175
  // Create quads for all items found in index 2.
138
176
  for (let l = 0; l < values.length; l++) {
139
- parts[name2] = this._termFromId(entityKeys[values[l]], this._factory);
177
+ parts[name2] = this._termFromId(entityKeys[values[l]]);
140
178
  yield this._factory.quad(parts.subject, parts.predicate, parts.object, graph);
141
179
  }
142
180
  }
@@ -206,10 +244,10 @@ class N3Store {
206
244
  // ### `_getGraphs` returns an array with the given graph,
207
245
  // or all graphs if the argument is null or undefined.
208
246
  _getGraphs(graph) {
209
- if (!isString(graph)) return this._graphs;
210
- const graphs = {};
211
- graphs[graph] = this._graphs[graph];
212
- return graphs;
247
+ graph = graph === '' ? 1 : graph && (this._termToNumericId(graph) || -1);
248
+ return typeof graph !== 'number' ? this._graphs : {
249
+ [graph]: this._graphs[graph]
250
+ };
213
251
  }
214
252
 
215
253
  // ### `_uniqueEntities` returns a function that accepts an entity ID
@@ -241,7 +279,7 @@ class N3Store {
241
279
  if (!predicate) graph = subject.graph, object = subject.object, predicate = subject.predicate, subject = subject.subject;
242
280
 
243
281
  // Convert terms to internal string representation
244
- graph = (0, _N3DataFactory.termToId)(graph);
282
+ graph = graph ? this._termToNewNumericId(graph) : 1;
245
283
 
246
284
  // Find the graph that will contain the triple
247
285
  let graphItem = this._graphs[graph];
@@ -307,9 +345,8 @@ class N3Store {
307
345
  removeQuad(subject, predicate, object, graph) {
308
346
  // Shift arguments if a quad object is given instead of components
309
347
  if (!predicate) graph = subject.graph, object = subject.object, predicate = subject.predicate, subject = subject.subject;
310
-
311
348
  // Convert terms to internal string representation
312
- graph = (0, _N3DataFactory.termToId)(graph);
349
+ graph = graph ? this._termToNumericId(graph) : 1;
313
350
 
314
351
  // Find internal identifiers for all components
315
352
  // and verify the quad exists.
@@ -348,9 +385,19 @@ class N3Store {
348
385
  const stream = new _readableStream.Readable({
349
386
  objectMode: true
350
387
  });
351
- stream._read = () => {
352
- for (const quad of this.readQuads(subject, predicate, object, graph)) stream.push(quad);
353
- stream.push(null);
388
+ const iterable = this.readQuads(subject, predicate, object, graph);
389
+ stream._read = size => {
390
+ while (size-- > 0) {
391
+ const {
392
+ done,
393
+ value
394
+ } = iterable.next();
395
+ if (done) {
396
+ stream.push(null);
397
+ return;
398
+ }
399
+ stream.push(value);
400
+ }
354
401
  };
355
402
  return this.remove(stream);
356
403
  }
@@ -369,8 +416,6 @@ class N3Store {
369
416
  // ### `readQuads` returns an generator of quads matching a pattern.
370
417
  // Setting any field to `undefined` or `null` indicates a wildcard.
371
418
  *readQuads(subject, predicate, object, graph) {
372
- // Convert terms to internal string representation
373
- graph = graph && (0, _N3DataFactory.termToId)(graph);
374
419
  const graphs = this._getGraphs(graph);
375
420
  let content, subjectId, predicateId, objectId;
376
421
 
@@ -404,14 +449,14 @@ class N3Store {
404
449
  // Setting any field to `undefined` or `null` indicates a wildcard.
405
450
  // For backwards compatibility, the object return also implements the Readable stream interface.
406
451
  match(subject, predicate, object, graph) {
407
- return new DatasetCoreAndReadableStream(this, subject, predicate, object, graph);
452
+ return new DatasetCoreAndReadableStream(this, subject, predicate, object, graph, {
453
+ entityIndex: this._entityIndex
454
+ });
408
455
  }
409
456
 
410
457
  // ### `countQuads` returns the number of quads matching a pattern.
411
458
  // Setting any field to `undefined` or `null` indicates a wildcard.
412
459
  countQuads(subject, predicate, object, graph) {
413
- // Convert terms to internal string representation
414
- graph = graph && (0, _N3DataFactory.termToId)(graph);
415
460
  const graphs = this._getGraphs(graph);
416
461
  let count = 0,
417
462
  content,
@@ -485,8 +530,6 @@ class N3Store {
485
530
  // ### `forSubjects` executes the callback on all subjects that match the pattern.
486
531
  // Setting any field to `undefined` or `null` indicates a wildcard.
487
532
  forSubjects(callback, predicate, object, graph) {
488
- // Convert terms to internal string representation
489
- graph = graph && (0, _N3DataFactory.termToId)(graph);
490
533
  const graphs = this._getGraphs(graph);
491
534
  let content, predicateId, objectId;
492
535
  callback = this._uniqueEntities(callback);
@@ -525,8 +568,6 @@ class N3Store {
525
568
  // ### `forPredicates` executes the callback on all predicates that match the pattern.
526
569
  // Setting any field to `undefined` or `null` indicates a wildcard.
527
570
  forPredicates(callback, subject, object, graph) {
528
- // Convert terms to internal string representation
529
- graph = graph && (0, _N3DataFactory.termToId)(graph);
530
571
  const graphs = this._getGraphs(graph);
531
572
  let content, subjectId, objectId;
532
573
  callback = this._uniqueEntities(callback);
@@ -565,8 +606,6 @@ class N3Store {
565
606
  // ### `forObjects` executes the callback on all objects that match the pattern.
566
607
  // Setting any field to `undefined` or `null` indicates a wildcard.
567
608
  forObjects(callback, subject, predicate, graph) {
568
- // Convert terms to internal string representation
569
- graph = graph && (0, _N3DataFactory.termToId)(graph);
570
609
  const graphs = this._getGraphs(graph);
571
610
  let content, subjectId, predicateId;
572
611
  callback = this._uniqueEntities(callback);
@@ -609,28 +648,13 @@ class N3Store {
609
648
  this.some(quad => {
610
649
  callback(quad.graph);
611
650
  return true; // Halt iteration of some()
612
- }, subject, predicate, object, graph);
651
+ }, subject, predicate, object, this._termFromId(this._entities[graph]));
613
652
  }
614
653
  }
615
654
 
616
655
  // ### `createBlankNode` creates a new blank node, returning its name
617
656
  createBlankNode(suggestedName) {
618
- let name, index;
619
- // Generate a name based on the suggested name
620
- if (suggestedName) {
621
- name = suggestedName = `_:${suggestedName}`, index = 1;
622
- while (this._ids[name]) name = suggestedName + index++;
623
- }
624
- // Generate a generic blank node name
625
- else {
626
- do {
627
- name = `_:b${this._blankNodeIndex++}`;
628
- } while (this._ids[name]);
629
- }
630
- // Add the blank node to the entities, avoiding the generation of duplicates
631
- this._ids[name] = ++this._id;
632
- this._entities[this._id] = name;
633
- return this._factory.blankNode(name.substr(2));
657
+ return this._entityIndex.createBlankNode(suggestedName);
634
658
  }
635
659
 
636
660
  // ### `extractLists` finds and removes all list triples
@@ -724,17 +748,12 @@ class N3Store {
724
748
  }
725
749
  }
726
750
 
727
- // Determines whether the argument is a string
728
- exports.default = N3Store;
729
- function isString(s) {
730
- return typeof s === 'string' || s instanceof String;
731
- }
732
-
733
751
  /**
734
752
  * A class that implements both DatasetCore and Readable.
735
753
  */
754
+ exports.default = N3Store;
736
755
  class DatasetCoreAndReadableStream extends _readableStream.Readable {
737
- constructor(n3Store, subject, predicate, object, graph) {
756
+ constructor(n3Store, subject, predicate, object, graph, options) {
738
757
  super({
739
758
  objectMode: true
740
759
  });
@@ -743,7 +762,8 @@ class DatasetCoreAndReadableStream extends _readableStream.Readable {
743
762
  subject,
744
763
  predicate,
745
764
  object,
746
- graph
765
+ graph,
766
+ options
747
767
  });
748
768
  }
749
769
  get filtered() {
@@ -756,7 +776,8 @@ class DatasetCoreAndReadableStream extends _readableStream.Readable {
756
776
  subject
757
777
  } = this;
758
778
  const newStore = this._filtered = new N3Store({
759
- factory: n3Store._factory
779
+ factory: n3Store._factory,
780
+ entityIndex: this.options.entityIndex
760
781
  });
761
782
  for (const quad of n3Store.readQuads(subject, predicate, object, graph)) newStore.addQuad(quad);
762
783
  }
@@ -765,9 +786,20 @@ class DatasetCoreAndReadableStream extends _readableStream.Readable {
765
786
  get size() {
766
787
  return this.filtered.size;
767
788
  }
768
- _read() {
769
- for (const quad of this) this.push(quad);
770
- this.push(null);
789
+ _read(size) {
790
+ if (size > 0 && !this[ITERATOR]) this[ITERATOR] = this[Symbol.iterator]();
791
+ const iterable = this[ITERATOR];
792
+ while (size-- > 0) {
793
+ const {
794
+ done,
795
+ value
796
+ } = iterable.next();
797
+ if (done) {
798
+ this.push(null);
799
+ return;
800
+ }
801
+ this.push(value);
802
+ }
771
803
  }
772
804
  add(quad) {
773
805
  return this.filtered.add(quad);
@@ -779,7 +811,7 @@ class DatasetCoreAndReadableStream extends _readableStream.Readable {
779
811
  return this.filtered.has(quad);
780
812
  }
781
813
  match(subject, predicate, object, graph) {
782
- return new DatasetCoreAndReadableStream(this.filtered, subject, predicate, object, graph);
814
+ return new DatasetCoreAndReadableStream(this.filtered, subject, predicate, object, graph, this.options);
783
815
  }
784
816
  *[Symbol.iterator]() {
785
817
  yield* this._filtered || this.n3Store.readQuads(this.subject, this.predicate, this.object, this.graph);
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  var _readableStream = require("readable-stream");
8
8
  var _N3Parser = _interopRequireDefault(require("./N3Parser"));
9
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
10
  // **N3StreamParser** parses a text stream into a quad stream.
11
11
 
12
12
  // ## Constructor
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  var _readableStream = require("readable-stream");
8
8
  var _N3Writer = _interopRequireDefault(require("./N3Writer"));
9
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
10
  // **N3StreamWriter** serializes a quad stream into a text stream.
11
11
 
12
12
  // ## Constructor
package/lib/N3Util.js CHANGED
@@ -12,7 +12,7 @@ exports.isVariable = isVariable;
12
12
  exports.prefix = prefix;
13
13
  exports.prefixes = prefixes;
14
14
  var _N3DataFactory = _interopRequireDefault(require("./N3DataFactory"));
15
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
16
16
  // **N3Util** provides N3 utility functions.
17
17
 
18
18
  // Tests whether the given term represents an IRI
package/lib/N3Writer.js CHANGED
@@ -8,8 +8,8 @@ var _IRIs = _interopRequireDefault(require("./IRIs"));
8
8
  var _N3DataFactory = _interopRequireWildcard(require("./N3DataFactory"));
9
9
  var _N3Util = require("./N3Util");
10
10
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
11
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
12
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
13
  // **N3Writer** writes N3 documents.
14
14
 
15
15
  const DEFAULTGRAPH = _N3DataFactory.default.defaultGraph();
@@ -218,7 +218,7 @@ class N3Writer {
218
218
  }
219
219
  }
220
220
 
221
- // ### `_encodeQuad` encodes an RDF* quad
221
+ // ### `_encodeQuad` encodes an RDF-star quad
222
222
  _encodeQuad({
223
223
  subject,
224
224
  predicate,
package/lib/index.js CHANGED
@@ -21,6 +21,12 @@ Object.defineProperty(exports, "DefaultGraph", {
21
21
  return _N3DataFactory.DefaultGraph;
22
22
  }
23
23
  });
24
+ Object.defineProperty(exports, "EntityIndex", {
25
+ enumerable: true,
26
+ get: function () {
27
+ return _N3Store.N3EntityIndex;
28
+ }
29
+ });
24
30
  Object.defineProperty(exports, "Lexer", {
25
31
  enumerable: true,
26
32
  get: function () {
@@ -110,15 +116,15 @@ Object.defineProperty(exports, "termToId", {
110
116
  var _N3Lexer = _interopRequireDefault(require("./N3Lexer"));
111
117
  var _N3Parser = _interopRequireDefault(require("./N3Parser"));
112
118
  var _N3Writer = _interopRequireDefault(require("./N3Writer"));
113
- var _N3Store = _interopRequireDefault(require("./N3Store"));
119
+ var _N3Store = _interopRequireWildcard(require("./N3Store"));
114
120
  var _N3StreamParser = _interopRequireDefault(require("./N3StreamParser"));
115
121
  var _N3StreamWriter = _interopRequireDefault(require("./N3StreamWriter"));
116
122
  var Util = _interopRequireWildcard(require("./N3Util"));
117
123
  exports.Util = Util;
118
124
  var _N3DataFactory = _interopRequireWildcard(require("./N3DataFactory"));
119
125
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
120
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
121
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
126
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
127
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
122
128
  // Named exports
123
129
  // Export all named exports as a default object for backward compatibility
124
130
  var _default = exports.default = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n3",
3
- "version": "1.17.4",
3
+ "version": "1.17.6",
4
4
  "description": "Lightning fast, asynchronous, streaming Turtle / N3 / RDF library.",
5
5
  "author": "Ruben Verborgh <ruben.verborgh@gmail.com>",
6
6
  "keywords": [
package/src/N3Parser.js CHANGED
@@ -239,7 +239,7 @@ export default class N3Parser {
239
239
  break;
240
240
  case '<<':
241
241
  if (!this._supportsRDFStar)
242
- return this._error('Unexpected RDF* syntax', token);
242
+ return this._error('Unexpected RDF-star syntax', token);
243
243
  this._saveContext('<<', this._graph, null, null, null);
244
244
  this._graph = null;
245
245
  return this._readSubject;
@@ -328,7 +328,7 @@ export default class N3Parser {
328
328
  return this._readSubject;
329
329
  case '<<':
330
330
  if (!this._supportsRDFStar)
331
- return this._error('Unexpected RDF* syntax', token);
331
+ return this._error('Unexpected RDF-star syntax', token);
332
332
  this._saveContext('<<', this._graph, this._subject, this._predicate, null);
333
333
  this._graph = null;
334
334
  return this._readSubject;
@@ -617,7 +617,7 @@ export default class N3Parser {
617
617
  // {| means that the current triple is annotated with predicate-object pairs.
618
618
  case '{|':
619
619
  if (!this._supportsRDFStar)
620
- return this._error('Unexpected RDF* syntax', token);
620
+ return this._error('Unexpected RDF-star syntax', token);
621
621
  // Continue using the last triple as quoted triple subject for the predicate-object pairs.
622
622
  const predicate = this._predicate, object = this._object;
623
623
  this._subject = this._quad(subject, predicate, object, this.DEFAULTGRAPH);
@@ -851,7 +851,7 @@ export default class N3Parser {
851
851
  return this._readPath;
852
852
  }
853
853
 
854
- // ### `_readRDFStarTailOrGraph` reads the graph of a nested RDF* quad or the end of a nested RDF* triple
854
+ // ### `_readRDFStarTailOrGraph` reads the graph of a nested RDF-star quad or the end of a nested RDF-star triple
855
855
  _readRDFStarTailOrGraph(token) {
856
856
  if (token.type !== '>>') {
857
857
  // An entity means this is a quad (only allowed if not already inside a graph)
@@ -862,7 +862,7 @@ export default class N3Parser {
862
862
  return this._readRDFStarTail(token);
863
863
  }
864
864
 
865
- // ### `_readRDFStarTail` reads the end of a nested RDF* triple
865
+ // ### `_readRDFStarTail` reads the end of a nested RDF-star triple
866
866
  _readRDFStarTail(token) {
867
867
  if (token.type !== '>>')
868
868
  return this._error(`Expected >> but got ${token.type}`, token);