@rotorsoft/act 1.31.16 → 1.31.18

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.
@@ -563,10 +563,8 @@ var InMemoryStream = class {
563
563
  * @returns The granted lease or undefined if blocked.
564
564
  */
565
565
  lease(lease, millis) {
566
- if (millis > 0) {
567
- this._leased_by = lease.by;
568
- this._leased_until = new Date(Date.now() + millis);
569
- }
566
+ this._leased_by = lease.by;
567
+ this._leased_until = new Date(Date.now() + millis);
570
568
  this._retry = this._retry + 1;
571
569
  return {
572
570
  stream: this.stream,
@@ -956,8 +954,8 @@ var InMemoryStore = class {
956
954
  } of streams) {
957
955
  const existing = this._streams.get(stream);
958
956
  if (existing) {
957
+ if (priority >= existing.priority) existing.lane = lane;
959
958
  existing.bump_priority(priority);
960
- existing.lane = lane;
961
959
  if (correlated_at2 !== void 0) existing.mark(correlated_at2);
962
960
  } else {
963
961
  const created = new InMemoryStream(stream, source, priority, lane);
@@ -1183,6 +1181,7 @@ var InMemoryStore = class {
1183
1181
  }
1184
1182
  if (blocked !== void 0 && s.blocked !== blocked) continue;
1185
1183
  if (query?.lane !== void 0 && s.lane !== query.lane) continue;
1184
+ if (count >= limit) break;
1186
1185
  callback({
1187
1186
  stream: s.stream,
1188
1187
  source: s.source,
@@ -1198,7 +1197,6 @@ var InMemoryStore = class {
1198
1197
  correlated_at: s.correlated_at
1199
1198
  });
1200
1199
  count++;
1201
- if (count >= limit) break;
1202
1200
  }
1203
1201
  return { maxEventId: this._events.at(-1)?.id ?? -1, count };
1204
1202
  }
@@ -1268,6 +1266,7 @@ var InMemoryStore = class {
1268
1266
  const ordered = [...acc.keys()].sort();
1269
1267
  const out = /* @__PURE__ */ new Map();
1270
1268
  for (const stream of ordered) {
1269
+ if (limit !== void 0 && out.size >= limit) break;
1271
1270
  if (after !== void 0 && stream <= after) continue;
1272
1271
  const a = acc.get(stream);
1273
1272
  const stats = { head: a.head };
@@ -1275,7 +1274,6 @@ var InMemoryStore = class {
1275
1274
  if (want_count) stats.count = a.count;
1276
1275
  if (want_names) stats.names = a.names;
1277
1276
  out.set(stream, stats);
1278
- if (limit !== void 0 && out.size >= limit) break;
1279
1277
  }
1280
1278
  return out;
1281
1279
  }