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 4.2.0 to 4.2.1

32

index.js

@@ -0,1 +1,13 @@

const events = require('events')
const mutexify = require('mutexify')
const thunky = require('thunky')
const codecs = require('codecs')
const bulk = require('bulk-write-stream')
const toStream = require('nanoiterator/to-stream')
const isOptions = require('is-options')
const hypercore = require('hypercore')
const inherits = require('inherits')
const alru = require('array-lru')
const Node = require('./lib/node')

@@ -11,11 +23,2 @@ const Get = require('./lib/get')

const { Header } = require('./lib/messages')
const mutexify = require('mutexify')
const thunky = require('thunky')
const codecs = require('codecs')
const bulk = require('bulk-write-stream')
const toStream = require('nanoiterator/to-stream')
const isOptions = require('is-options')
const hypercore = require('hypercore')
const inherits = require('inherits')
const events = require('events')

@@ -52,2 +55,3 @@ module.exports = HyperTrie

this._checkout = (opts && opts.checkout) || 0
this._cache = alru((opts && opts.cacheSize) || 32768)
this._lock = mutexify()

@@ -234,4 +238,11 @@

if (seq < 1) return process.nextTick(cb, null, null)
const self = this
const self = this
const cached = this._cache.get(seq)
if (cached) {
// early exit (see below)
if (!cached.value && !cached.key) return process.nextTick(cb, null, null)
return process.nextTick(cb, null, cached)
}
this.feed.get(seq, opts, onnode)

@@ -242,2 +253,3 @@

const node = Node.decode(val, seq, self.valueEncoding, self.hash)
self._cache.set(seq, node)
// early exit for the key: '' nodes we write to reset the db

@@ -244,0 +256,0 @@ if (!node.value && !node.key) return cb(null, null)

@@ -19,3 +19,2 @@ const sodium = require('sodium-universal')

this.keySplit = split(this.key)
this.flags = data.flags || 0
this.hash = userHash ? userHash(this.key) : hash(this.keySplit)

@@ -27,2 +26,6 @@ this.trie = data.trieBuffer ? trie.decode(data.trieBuffer) : (data.trie || [])

this.valueEncoding = enc
this._finalized = false
this._flags = data.flags || 0
this.flags = this._flags
}

@@ -38,3 +41,3 @@ Node.Flags = Flags

get: function () {
return !!(this.flags & Flags.HIDDEN)
return !!(this._flags & Flags.HIDDEN)
}

@@ -53,9 +56,11 @@ })

Node.prototype.final = function () {
if (!this.valueBuffer || this.value !== null) return this
this.value = this.valueEncoding ? this.valueEncoding.decode(this.valueBuffer) : this.valueBuffer
if (this._finalized) return this
if (this.valueBuffer === null) this.value = null
else this.value = this.valueEncoding ? this.valueEncoding.decode(this.valueBuffer) : this.valueBuffer
// The flags are shifted in order to both hide the internal flags and support user-defined flags.
this.flags = this.flags >> 8
this.flags = this._flags >> 8
this.valueBuffer = null
this._finalized = true
return this

@@ -62,0 +67,0 @@ }

{
"name": "hypertrie",
"version": "4.2.0",
"version": "4.2.1",
"description": "Distributed single writer key/value store",
"main": "index.js",
"dependencies": {
"array-lru": "^1.1.1",
"bulk-write-stream": "^1.1.4",

@@ -8,0 +9,0 @@ "codecs": "^2.0.0",

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