n3 1.20.1 → 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/lib/N3Store.js CHANGED
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n3",
3
- "version": "1.20.1",
3
+ "version": "1.20.2",
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/N3Store.js CHANGED
@@ -807,7 +807,24 @@ export default class N3Store {
807
807
  * Blank Nodes will be normalized.
808
808
  */
809
809
  contains(other) {
810
- return other.every(quad => this.has(quad));
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;
811
828
  }
812
829
 
813
830
  /**