@rotorsoft/act 1.23.4 → 1.23.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -576,11 +576,12 @@ var InMemoryStream = class {
576
576
  if (this._leased_by === lease.by) {
577
577
  this._leased_by = void 0;
578
578
  this._leased_until = void 0;
579
- this._retry = -1;
580
579
  if (lease.due !== void 0) {
580
+ this._retry = lease.retry;
581
581
  this._deferred_at = lease.due;
582
582
  return void 0;
583
583
  }
584
+ this._retry = -1;
584
585
  this._at = lease.at;
585
586
  this._deferred_at = void 0;
586
587
  return {
@@ -742,7 +743,18 @@ var InMemoryStore = class {
742
743
  async query(callback, query) {
743
744
  await sleep();
744
745
  let count = 0;
746
+ let floor_index = -1;
747
+ if (query?.with_snaps && query.stream_exact && query.stream !== void 0 && query.after === void 0) {
748
+ for (let j = this._events.length - 1; j >= 0; j--) {
749
+ const e = this._events[j];
750
+ if (e.stream === query.stream && e.name === SNAP_EVENT) {
751
+ floor_index = j;
752
+ break;
753
+ }
754
+ }
755
+ }
745
756
  if (query?.backward) {
757
+ const floor_id = floor_index >= 0 ? this._events[floor_index].id : -1;
746
758
  let i = (query?.before !== void 0 ? this._first_index_after(query.before - 1) : this._events.length) - 1;
747
759
  while (i >= 0) {
748
760
  const e = this._events[i--];
@@ -750,6 +762,7 @@ var InMemoryStore = class {
750
762
  if (query?.created_before && e.created >= query.created_before)
751
763
  continue;
752
764
  if (query.after !== void 0 && e.id <= query.after) break;
765
+ if (floor_id >= 0 && e.id < floor_id) break;
753
766
  if (query.created_after && e.created <= query.created_after) continue;
754
767
  await Promise.resolve(
755
768
  callback(this._with_pii(e))
@@ -758,16 +771,7 @@ var InMemoryStore = class {
758
771
  if (query?.limit && count >= query.limit) break;
759
772
  }
760
773
  } else {
761
- let i = this._first_index_after(query?.after ?? -1);
762
- if (query?.with_snaps && query.stream_exact && query.stream !== void 0 && query.after === void 0 && query.created_before === void 0 && query.created_after === void 0) {
763
- for (let j = this._events.length - 1; j >= 0; j--) {
764
- const e = this._events[j];
765
- if (e.stream === query.stream && e.name === SNAP_EVENT) {
766
- i = j;
767
- break;
768
- }
769
- }
770
- }
774
+ let i = floor_index >= 0 ? floor_index : this._first_index_after(query?.after ?? -1);
771
775
  while (i < this._events.length) {
772
776
  const e = this._events[i++];
773
777
  if (query && !this.in_query(query, e)) continue;