Socket
Socket
Sign inDemoInstall

hyperbee

Package Overview
Dependencies
Maintainers
2
Versions
108
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hyperbee - npm Package Compare versions

Comparing version 2.2.0 to 2.3.0

27

index.js

@@ -5,2 +5,3 @@ const codecs = require('codecs')

const b4a = require('b4a')
const safetyCatch = require('safety-catch')

@@ -428,2 +429,16 @@ const RangeIterator = require('./iterators/range')

}
static async isHyperbee (core, opts) {
await core.ready()
if (core.length === 0) return false
const blk0 = await core.get(0, opts)
try {
return Header.decode(blk0).protocol === 'hyperbee'
} catch (err) { // undecodable
safetyCatch(err)
return false
}
}
}

@@ -446,2 +461,3 @@

this.isSnapshot = this.feed !== this.tree.feed
this.shouldUpdate = this.options.update !== false
this.encoding = {

@@ -466,4 +482,3 @@ key: options.keyEncoding ? codecs(options.keyEncoding) : tree.keyEncoding,

async getRoot (ensureHeader, opts) {
opts = { ...opts, ...this.options }
async getRoot (ensureHeader) {
await this.ready()

@@ -478,5 +493,5 @@ if (ensureHeader) {

}
if (this.tree._checkout === 0 && (opts && opts.update) !== false) await this.feed.update()
if (this.tree._checkout === 0 && this.shouldUpdate) await this.feed.update()
if (this.version < 2) return null
return (await this.getBlock(this.version - 1, opts)).getTreeNode(0)
return (await this.getBlock(this.version - 1)).getTreeNode(0)
}

@@ -488,3 +503,3 @@

async getBlock (seq, opts = this.options) {
async getBlock (seq) {
if (this.rootSeq === 0) this.rootSeq = seq

@@ -494,3 +509,3 @@ let b = this.blocks && this.blocks.get(seq)

this.onseq(seq)
const entry = await this.feed.get(seq, { ...opts, valueEncoding: Node })
const entry = await this.feed.get(seq, { ...this.options, valueEncoding: Node })
if (entry === null) throw new Error('Block not available locally')

@@ -497,0 +512,0 @@ b = new BlockEntry(seq, this, entry)

@@ -30,6 +30,6 @@ module.exports = class HistoryIterator {

if (this.lt <= 1) return null
return final(await this.batch.getBlock(--this.lt, this.options), this.encoding)
return final(await this.batch.getBlock(--this.lt), this.encoding)
}
return final(await this.batch.getBlock(this.gte++, this.options), this.encoding)
return final(await this.batch.getBlock(this.gte++), this.encoding)
}

@@ -36,0 +36,0 @@

{
"name": "hyperbee",
"version": "2.2.0",
"version": "2.3.0",
"description": "An append-only B-tree running on a Hypercore.",

@@ -16,2 +16,3 @@ "main": "index.js",

"protocol-buffers-encodings": "^1.2.0",
"safety-catch": "^1.0.2",
"streamx": "^2.12.4"

@@ -33,3 +34,3 @@ },

"type": "git",
"url": "https://github.com/hypercore-protocol/hyperbee.git"
"url": "https://github.com/holepunchto/hyperbee.git"
},

@@ -39,5 +40,5 @@ "author": "Mathias Buus (@mafintosh)",

"bugs": {
"url": "https://github.com/hypercore-protocol/hyperbee/issues"
"url": "https://github.com/holepunchto/hyperbee/issues"
},
"homepage": "https://github.com/hypercore-protocol/hyperbee"
"homepage": "https://github.com/holepunchto/hyperbee"
}
# Hyperbee 🐝
[See API docs at docs.holepunch.to](https://docs.holepunch.to/building-blocks/hyperbee)
An append-only B-tree running on a Hypercore.

@@ -51,3 +53,3 @@ Allows sorted iteration and more.

Make a new Hyperbee instance. `feed` should be a [Hypercore](https://github.com/hypercore-protocol/hypercore).
Make a new Hyperbee instance. `feed` should be a [Hypercore](https://github.com/holepunchto/hypercore).

@@ -274,1 +276,7 @@ Options include:

Makes sure internal state is loaded. Call this once before checking the version if you haven't called any of the other APIs.
#### `await Hyperbee.isHyperbee(core, opts?)`
Returns true if the core contains a hyperbee, false otherwise.
Queries the core, so ensure it is available and has updated length before calling this.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc