Skip to content

Commit

Permalink
fix: make sure default behaviour of quad is addition
Browse files Browse the repository at this point in the history
  • Loading branch information
maartyman committed Jan 22, 2025
1 parent 197d206 commit 9f5320d
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions packages/streaming-store/lib/StreamingStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export class StreamingStore<Q extends Quad>
}

private handleQuad(quad: Q): void {
quad.isAddition = quad.isAddition ?? true;
if (quad.isAddition ? this.store.has(quad) : !this.store.has(quad)) {
return;
}
Expand Down Expand Up @@ -97,9 +98,7 @@ export class StreamingStore<Q extends Quad>
}

stream.on('data', (quad: Q) => {
if (quad.isAddition === undefined) {
quad.isAddition = false;
}
quad.isAddition = quad.isAddition ?? false;
if (this.halted) {
this.haltBuffer.push(quad);
} else {
Expand All @@ -115,9 +114,7 @@ export class StreamingStore<Q extends Quad>
}

stream.on('data', (quad: Q) => {
if (quad.isAddition === undefined) {
quad.isAddition = true;
}
quad.isAddition = quad.isAddition ?? true;
if (this.halted) {
this.haltBuffer.push(quad);
} else {
Expand All @@ -131,9 +128,7 @@ export class StreamingStore<Q extends Quad>
if (this.ended) {
throw new Error('Attempted to add a quad into an ended StreamingStore.');
}
if (quad.isAddition === undefined) {
quad.isAddition = true;
}
quad.isAddition = quad.isAddition ?? true;
if (this.halted) {
this.haltBuffer.push(quad);
} else {
Expand All @@ -146,9 +141,7 @@ export class StreamingStore<Q extends Quad>
if (this.ended) {
throw new Error('Attempted to remove a quad of an ended StreamingStore.');
}
if (quad.isAddition === undefined) {
quad.isAddition = false;
}
quad.isAddition = quad.isAddition ?? false;
if (this.halted) {
this.haltBuffer.push(quad);
} else {
Expand Down

0 comments on commit 9f5320d

Please sign in to comment.