From 772268fbc0a56f1e936684894e8a7aad3c2aaae6 Mon Sep 17 00:00:00 2001 From: Mike Christensen Date: Fri, 20 Oct 2023 12:47:36 +0100 Subject: [PATCH] middleware: descriptive message before method --- src/stream/Middleware.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/stream/Middleware.ts b/src/stream/Middleware.ts index 8e6f579c..b296c847 100644 --- a/src/stream/Middleware.ts +++ b/src/stream/Middleware.ts @@ -129,6 +129,10 @@ export class OrderedHistoryResumer extends MiddlewareBase { return this.eventOrderer(a, b) * -1; } + private messageBeforeInclusive(a: string, b: string) { + return this.eventOrderer(a, b) <= 0; + } + public get state() { return this.currentState; } @@ -162,7 +166,7 @@ export class OrderedHistoryResumer extends MiddlewareBase { // Seek backwards through history until we reach a message id <= the specified sequenceID. // Discard anything older (>= sequenceID) and flush out the remaining messages. for (let i = 0; i < this.historicalMessages.length; i++) { - if (this.eventOrderer(this.historicalMessages[i].id, this.sequenceID) <= 0) { + if (this.messageBeforeInclusive(this.historicalMessages[i].id, this.sequenceID)) { this.historicalMessages.splice(i); this.flush(); return true;