From 9f5320d7e3bd5514c650c9d71105405675b047e5 Mon Sep 17 00:00:00 2001 From: maartenvandenbrande Date: Wed, 22 Jan 2025 20:34:16 +0100 Subject: [PATCH] fix: make sure default behaviour of quad is addition --- packages/streaming-store/lib/StreamingStore.ts | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/packages/streaming-store/lib/StreamingStore.ts b/packages/streaming-store/lib/StreamingStore.ts index 3c41024..19e3ff6 100644 --- a/packages/streaming-store/lib/StreamingStore.ts +++ b/packages/streaming-store/lib/StreamingStore.ts @@ -52,6 +52,7 @@ export class StreamingStore } private handleQuad(quad: Q): void { + quad.isAddition = quad.isAddition ?? true; if (quad.isAddition ? this.store.has(quad) : !this.store.has(quad)) { return; } @@ -97,9 +98,7 @@ export class StreamingStore } 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 { @@ -115,9 +114,7 @@ export class StreamingStore } 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 { @@ -131,9 +128,7 @@ export class StreamingStore 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 { @@ -146,9 +141,7 @@ export class StreamingStore 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 {