diff --git a/src/EventStore.js b/src/EventStore.js index 8bd003d..c70f872 100644 --- a/src/EventStore.js +++ b/src/EventStore.js @@ -26,6 +26,7 @@ class EventStore extends Store { get (hash) { return this.iterator({ gte: hash, limit: 1 }).collect()[0] } + iterator (options) { const messages = this._query(options) let currentIndex = 0 @@ -50,7 +51,7 @@ class EventStore extends Store { _query (opts) { if (!opts) opts = {} - const amount = opts.limit ? (opts.limit > -1 ? opts.limit : this._index.get().length) : 1 // Return 1 if no limit is provided + const amount = !opts.limit || opts.limit == 0 ? this._index.get().length : opts.limit; // Return all by default. const events = this._index.get().slice() let result = []