n3 1.20.0 → 1.20.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/browser/n3.min.js +1 -1
- package/lib/N3DataFactory.js +1 -1
- package/lib/N3Store.js +18 -3
- package/package.json +1 -1
- package/src/N3DataFactory.js +1 -1
- package/src/N3Store.js +21 -3
package/lib/N3DataFactory.js
CHANGED
|
@@ -11,7 +11,7 @@ exports.unescapeQuotes = unescapeQuotes;
|
|
|
11
11
|
var _IRIs = _interopRequireDefault(require("./IRIs"));
|
|
12
12
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
13
|
// N3.js implementations of the RDF/JS core data types
|
|
14
|
-
// See
|
|
14
|
+
// See http://rdf.js.org/data-model-spec/
|
|
15
15
|
|
|
16
16
|
const {
|
|
17
17
|
rdf,
|
package/lib/N3Store.js
CHANGED
|
@@ -302,13 +302,13 @@ class N3Store {
|
|
|
302
302
|
subject = this._termToNewNumericId(subject);
|
|
303
303
|
predicate = this._termToNewNumericId(predicate);
|
|
304
304
|
object = this._termToNewNumericId(object);
|
|
305
|
-
|
|
305
|
+
if (!this._addToIndex(graphItem.subjects, subject, predicate, object)) return false;
|
|
306
306
|
this._addToIndex(graphItem.predicates, predicate, object, subject);
|
|
307
307
|
this._addToIndex(graphItem.objects, object, subject, predicate);
|
|
308
308
|
|
|
309
309
|
// The cached quad count is now invalid
|
|
310
310
|
this._size = null;
|
|
311
|
-
return
|
|
311
|
+
return true;
|
|
312
312
|
}
|
|
313
313
|
|
|
314
314
|
// ### `addQuads` adds multiple quads to the store
|
|
@@ -759,7 +759,22 @@ class N3Store {
|
|
|
759
759
|
* Blank Nodes will be normalized.
|
|
760
760
|
*/
|
|
761
761
|
contains(other) {
|
|
762
|
-
return other.every(quad => this.has(quad));
|
|
762
|
+
if (!(other instanceof N3Store) || this._entityIndex !== other._entityIndex) return other.every(quad => this.has(quad));
|
|
763
|
+
const g1 = this._graphs,
|
|
764
|
+
g2 = other._graphs;
|
|
765
|
+
let s1, s2, p1, p2, o1;
|
|
766
|
+
for (const graph in g2) {
|
|
767
|
+
if (!(s1 = g1[graph])) return false;
|
|
768
|
+
s1 = s1.subjects;
|
|
769
|
+
for (const subject in s2 = g2[graph].subjects) {
|
|
770
|
+
if (!(p1 = s1[subject])) return false;
|
|
771
|
+
for (const predicate in p2 = s2[subject]) {
|
|
772
|
+
if (!(o1 = p1[predicate])) return false;
|
|
773
|
+
for (const object in p2[predicate]) if (!(object in o1)) return false;
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
return true;
|
|
763
778
|
}
|
|
764
779
|
|
|
765
780
|
/**
|
package/package.json
CHANGED
package/src/N3DataFactory.js
CHANGED
package/src/N3Store.js
CHANGED
|
@@ -306,13 +306,14 @@ export default class N3Store {
|
|
|
306
306
|
predicate = this._termToNewNumericId(predicate);
|
|
307
307
|
object = this._termToNewNumericId(object);
|
|
308
308
|
|
|
309
|
-
|
|
309
|
+
if (!this._addToIndex(graphItem.subjects, subject, predicate, object))
|
|
310
|
+
return false;
|
|
310
311
|
this._addToIndex(graphItem.predicates, predicate, object, subject);
|
|
311
312
|
this._addToIndex(graphItem.objects, object, subject, predicate);
|
|
312
313
|
|
|
313
314
|
// The cached quad count is now invalid
|
|
314
315
|
this._size = null;
|
|
315
|
-
return
|
|
316
|
+
return true;
|
|
316
317
|
}
|
|
317
318
|
|
|
318
319
|
// ### `addQuads` adds multiple quads to the store
|
|
@@ -806,7 +807,24 @@ export default class N3Store {
|
|
|
806
807
|
* Blank Nodes will be normalized.
|
|
807
808
|
*/
|
|
808
809
|
contains(other) {
|
|
809
|
-
|
|
810
|
+
if (!(other instanceof N3Store) || this._entityIndex !== other._entityIndex)
|
|
811
|
+
return other.every(quad => this.has(quad));
|
|
812
|
+
|
|
813
|
+
const g1 = this._graphs, g2 = other._graphs;
|
|
814
|
+
let s1, s2, p1, p2, o1;
|
|
815
|
+
for (const graph in g2) {
|
|
816
|
+
if (!(s1 = g1[graph])) return false;
|
|
817
|
+
s1 = s1.subjects;
|
|
818
|
+
for (const subject in (s2 = g2[graph].subjects)) {
|
|
819
|
+
if (!(p1 = s1[subject])) return false;
|
|
820
|
+
for (const predicate in (p2 = s2[subject])) {
|
|
821
|
+
if (!(o1 = p1[predicate])) return false;
|
|
822
|
+
for (const object in p2[predicate])
|
|
823
|
+
if (!(object in o1)) return false;
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
return true;
|
|
810
828
|
}
|
|
811
829
|
|
|
812
830
|
/**
|