Skip to content
This repository was archived by the owner on Sep 30, 2023. It is now read-only.

Return all entries by default for iterator #38

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/EventStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 == -1 ? this._index.get().length : Math.abs(opts.limit); // Return all by default.
const events = this._index.get().slice()
let result = []

Expand Down