if (subject && !(subjectId = newStore._termToNumericId(subject)) ||
predicate && !(predicateId = newStore._termToNumericId(predicate)) ||
object && !(objectId = newStore._termToNumericId(object)))
return newStore;
const graphs = n3Store._getGraphs(graph);
for (const graphKey in graphs) {
let subjects, predicates, objects, content;
if (content = graphs[graphKey]) {
if (!subjectId && predicateId) {
if (predicates = indexMatch(content.predicates, [predicateId, objectId, subjectId])) {
subjects = indexMatch(content.subjects, [subjectId, predicateId, objectId]);
objects = indexMatch(content.objects, [objectId, subjectId, predicateId]);
}
}
else if (objectId) {
if (objects = indexMatch(content.objects, [objectId, subjectId, predicateId])) {
subjects = indexMatch(content.subjects, [subjectId, predicateId, objectId]);
predicates = indexMatch(content.predicates, [predicateId, objectId, subjectId]);
}
}
else if (subjects = indexMatch(content.subjects, [subjectId, predicateId, objectId])) {
predicates = indexMatch(content.predicates, [predicateId, objectId, subjectId]);
objects = indexMatch(content.objects, [objectId, subjectId, predicateId]);
}
if (subjects)
newStore._graphs[graphKey] = { subjects, predicates, objects };
}
}
newStore._size = null;
}
return this._filtered;
}
get size() {
return this.filtered.size;
}
_read(size) {
if (size > 0 && !this[ITERATOR])
this[ITERATOR] = this[Symbol.iterator]();
const iterable = this[ITERATOR];
while (--size >= 0) {
const { done, value } = iterable.next();
if (done) {
this.push(null);
return;
}
this.push(value);
}
}
addAll(quads) {
return this.filtered.addAll(quads);
}
contains(other) {
return this.filtered.contains(other);
}
deleteMatches(subject, predicate, object, graph) {
return this.filtered.deleteMatches(subject, predicate, object, graph);
}
difference(other) {
return this.filtered.difference(other);
}
equals(other) {
return this.filtered.equals(other);
}
every(callback, subject, predicate, object, graph) {
return this.filtered.every(callback, subject, predicate, object, graph);
}
filter(iteratee) {
return this.filtered.filter(iteratee);
}
forEach(callback, subject, predicate, object, graph) {
return this.filtered.forEach(callback, subject, predicate, object, graph);
}
import(stream) {
return this.filtered.import(stream);
}
intersection(other) {
return this.filtered.intersection(other);
}
map(iteratee) {
return this.filtered.map(iteratee);
}
some(callback, subject, predicate, object, graph) {
return this.filtered.some(callback, subject, predicate, object, graph);
}
toCanonical() {
return this.filtered.toCanonical();
}
toStream() {
return this._filtered ?
this._filtered.toStream()
: this.n3Store.match(this.subject, this.predicate, this.object, this.graph);
}
union(quads) {
return this._filtered ?
this._filtered.union(quads)
: this.n3Store.match(this.subject, this.predicate, this.object, this.graph).addAll(quads);
}
toArray() {
return this._filtered ? this._filtered.toArray() : this.n3Store.getQuads(this.subject, this.predicate, this.object, this.graph);
}
reduce(callback, initialValue) {
return this.filtered.reduce(callback, initialValue);
}
toString() {
return (new N3Writer()).quadsToString(this);
}
add(quad) {
return this.filtered.add(quad);
}
delete(quad) {
return this.filtered.delete(quad);
}
has(quad) {
return this.filtered.has(quad);
}
match(subject, predicate, object, graph) {
return new DatasetCoreAndReadableStream(this.filtered, subject, predicate, object, graph, this.options);
}
*[Symbol.iterator]() {
yield* this._filtered || this.n3Store.readQuads(this.subject, this.predicate, this.object, this.graph);
}
}