Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hypertrie

Package Overview
Dependencies
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hypertrie - npm Package Compare versions

Comparing version 3.8.0 to 4.0.0

test/update.js

16

index.js

@@ -41,2 +41,3 @@ const Node = require('./lib/node')

this.valueEncoding = opts.valueEncoding ? codecs(opts.valueEncoding) : null
this.alwaysUpdate = !!opts.alwaysUpdate

@@ -113,4 +114,4 @@ const feedOpts = Object.assign({}, opts, { valueEncoding: 'binary' })

HyperTrie.prototype.replicate = function (opts) {
return this.feed.replicate(opts)
HyperTrie.prototype.replicate = function (isInitiator, opts) {
return this.feed.replicate(isInitiator, opts)
}

@@ -132,6 +133,13 @@

HyperTrie.prototype.head = function (cb) {
const self = this
if (!this.opened) return readyAndHead(this, cb)
if (this._checkout !== 0) return this.getBySeq(this._checkout - 1, cb)
if (this.feed.length < 2) return process.nextTick(cb, null, null)
this.getBySeq(this.feed.length - 1, cb)
if (this.alwaysUpdate) this.feed.update({ hash: false, ifAvailable: true }, onupdated)
else process.nextTick(onupdated)
function onupdated () {
if (self.feed.length < 2) return cb(null, null)
self.getBySeq(self.feed.length - 1, cb)
}
}

@@ -138,0 +146,0 @@

{
"name": "hypertrie",
"version": "3.8.0",
"version": "4.0.0",
"description": "Distributed single writer key/value store",

@@ -9,3 +9,3 @@ "main": "index.js",

"codecs": "^2.0.0",
"hypercore": "^7.0.0",
"hypercore": "^8.0.0",
"inherits": "^2.0.3",

@@ -24,2 +24,3 @@ "inspect-custom-symbol": "^1.1.0",

"compare": "^2.0.0",
"hypercore-protocol": "^7.1.1",
"protocol-buffers": "^4.0.4",

@@ -26,0 +27,0 @@ "random-access-memory": "^3.0.0",

@@ -35,3 +35,4 @@ # hypertrie

feed: aHypercore, // use this feed instead of loading storage
valueEncoding: 'json' // set value encoding
valueEncoding: 'json', // set value encoding
alwaysUpdate: true // perform an ifAvailable update prior to every head operation
}

@@ -128,6 +129,8 @@ ```

#### `stream = db.replicate([options])`
#### `stream = db.replicate(isInitiator, [options])`
Returns a hypercore replication stream for the db. Pipe this together with another hypertrie instance.
Replicate takes an `isInitiator` boolean which is used to indicate if this replication stream is the passive/active replicator.
All options are forwarded to hypercores replicate method.

@@ -134,0 +137,0 @@

@@ -77,6 +77,6 @@ const tape = require('tape')

const stream = db.replicate()
stream.pipe(clone.replicate()).pipe(stream)
const stream = db.replicate(true)
stream.pipe(clone.replicate(false)).pipe(stream)
})
})
})

Sorry, the diff of this file is not supported yet

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