Skip to content

Commit

Permalink
middleware: descriptive message before method
Browse files Browse the repository at this point in the history
  • Loading branch information
mschristensen committed Oct 20, 2023
1 parent 7aa5b12 commit 27d6aa7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/stream/Middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 27d6aa7

Please sign in to comment.