event-storage 1.3.3 → 1.3.4
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.
- package/package.json +1 -1
- package/src/EventStream.js +7 -7
- package/src/JoinEventStream.js +8 -3
package/package.json
CHANGED
package/src/EventStream.js
CHANGED
|
@@ -193,15 +193,15 @@ class EventStream extends stream.Readable {
|
|
|
193
193
|
* @returns {Array<object>}
|
|
194
194
|
*/
|
|
195
195
|
get events() {
|
|
196
|
-
if (this.
|
|
197
|
-
return this.
|
|
196
|
+
if (this.cachedEvents instanceof Array) {
|
|
197
|
+
return this.cachedEvents;
|
|
198
198
|
}
|
|
199
|
-
this.
|
|
199
|
+
this.cachedEvents = [];
|
|
200
200
|
let next;
|
|
201
201
|
while ((next = this.next()) !== false) {
|
|
202
|
-
this.
|
|
202
|
+
this.cachedEvents.push(next.payload);
|
|
203
203
|
}
|
|
204
|
-
return this.
|
|
204
|
+
return this.cachedEvents;
|
|
205
205
|
}
|
|
206
206
|
|
|
207
207
|
/**
|
|
@@ -242,7 +242,7 @@ class EventStream extends stream.Readable {
|
|
|
242
242
|
*/
|
|
243
243
|
reset() {
|
|
244
244
|
this._iterator = null;
|
|
245
|
-
this.
|
|
245
|
+
this.cachedEvents = null;
|
|
246
246
|
return this;
|
|
247
247
|
}
|
|
248
248
|
|
|
@@ -259,7 +259,7 @@ class EventStream extends stream.Readable {
|
|
|
259
259
|
this.predicate = predicate || null;
|
|
260
260
|
this.rawMatcher = null;
|
|
261
261
|
this._iterator = null;
|
|
262
|
-
this.
|
|
262
|
+
this.cachedEvents = null;
|
|
263
263
|
return this;
|
|
264
264
|
}
|
|
265
265
|
|
package/src/JoinEventStream.js
CHANGED
|
@@ -34,9 +34,14 @@ class JoinEventStream extends EventStream {
|
|
|
34
34
|
if (!streamIndex || streamIndex.length === 0) {
|
|
35
35
|
return emptyIterator;
|
|
36
36
|
}
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
|
|
37
|
+
const ascending = this.minRevision <= this.maxRevision;
|
|
38
|
+
const from = streamIndex.find(this.minRevision, ascending);
|
|
39
|
+
const until = streamIndex.find(this.maxRevision, !ascending);
|
|
40
|
+
if (
|
|
41
|
+
from === 0 ||
|
|
42
|
+
until === 0 ||
|
|
43
|
+
(ascending ? from > until : from < until)
|
|
44
|
+
) {
|
|
40
45
|
// find() returns 0 when the requested revision is outside the stream's range
|
|
41
46
|
// (e.g. minRevision > all entries, or maxRevision < all entries).
|
|
42
47
|
return emptyIterator;
|