Comparing version 0.0.1 to 0.0.2
@@ -274,3 +274,3 @@ const codecs = require('codecs') | ||
await this.ready() | ||
if (this._checkout !== 0 && !this.feed.writable && (opts && opts.update) !== false) await this.update() | ||
if (this._checkout === 0 && !this.feed.writable && (opts && opts.update) !== false) await this.update() | ||
const len = this._checkout || this.feed.length | ||
@@ -482,4 +482,3 @@ if (len < 2) return null | ||
let root | ||
let node = root = await this.getRoot() | ||
let node = await this.getRoot() | ||
if (!node) return | ||
@@ -486,0 +485,0 @@ |
@@ -6,12 +6,25 @@ module.exports = class HistoryIterator { | ||
this.live = !!opts.live | ||
this.since = opts.since || 1 | ||
this.since = opts.since || 0 | ||
this.end = 0 | ||
this.reverse = !!opts.reverse | ||
this.limit = typeof opts.limit === 'number' ? opts.limit : -1 | ||
} | ||
async open () { | ||
await this.db.ready() | ||
await this.db.getRoot() // does the update dance | ||
this.end = this.live ? Infinity : this.db.version | ||
if (this.since) return | ||
if (this.reverse) this.since = this.end - 1 | ||
else this.since = 1 | ||
} | ||
async next () { | ||
if (this._limit === 0) return null | ||
if (this._limit > 0) this._limit-- | ||
if (this.reverse) { | ||
if (this.since < 1) return null | ||
return this.db.getBlock(this.since--, this.options) | ||
} | ||
if (this.since >= this.end) return null | ||
@@ -18,0 +31,0 @@ return this.db.getBlock(this.since++, this.options) |
{ | ||
"name": "hyperbee", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "An append-only Btree running on a Hypercore.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
57113
17
1757