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.4.0 to 3.4.1

1

lib/batch.js

@@ -28,2 +28,3 @@ const Put = require('./put')

node.seq = this._offset + this._nodes.length
node.preencode()
this._nodes.push(node)

@@ -30,0 +31,0 @@ }

7

lib/del.js

@@ -48,7 +48,6 @@ const Put = require('./put')

const key = closest ? closest.key : ''
const val = closest ? closest.value : null
const valueBuffer = closest ? closest.valueBuffer : null
const hidden = closest ? closest.hidden : node.hidden
const self = this
if (this._condition) this._condition(node, oncondition)
if (this._condition) this._condition(node.final(), oncondition)
else del()

@@ -63,3 +62,3 @@

function del () {
self._put = new Put(self._db, key, val, { batch: self._batch, del: node.seq, hidden }, done)
self._put = new Put(self._db, key, null, { batch: self._batch, del: node.seq, hidden, valueBuffer }, done)
}

@@ -66,0 +65,0 @@

@@ -214,4 +214,4 @@ const Nanoiterator = require('nanoiterator')

key: left ? left.key : right.key,
left,
right
left: left && left.final(),
right: right && right.final()
})

@@ -218,0 +218,0 @@ }

@@ -53,3 +53,3 @@ const Node = require('./node')

this._callback(null, head)
this._callback(null, head.final())
}

@@ -56,0 +56,0 @@

@@ -42,3 +42,8 @@ const Nanoiterator = require('nanoiterator')

if (this._gte > this._lte) return cb(null, null)
this._db.getBySeq(this._reverse ? this._lte-- : this._gte++, cb)
this._db.getBySeq(this._reverse ? this._lte-- : this._gte++, done)
function done (err, node) {
if (err) return cb(err)
cb(null, node.final())
}
}

@@ -45,0 +50,0 @@

@@ -53,3 +53,3 @@ const Nanoiterator = require('nanoiterator')

if (i >= len) return cb(null, top.node)
if (i >= len) return cb(null, top.node.final())

@@ -56,0 +56,0 @@ const bucket = top.node.trie[i] || []

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

this.key = normalizeKey(data.key)
this.value = data.value !== undefined ? data.value : ((data.valueBuffer && enc) ? enc.decode(data.valueBuffer) : data.valueBuffer)
this.value = data.value !== undefined ? data.value : null
this.keySplit = split(this.key)

@@ -20,3 +20,3 @@ this.hidden = data.hidden || (data.flags ? !!(data.flags & 1) : false)

this.trieBuffer = null
this.valueBuffer = null
this.valueBuffer = data.valueBuffer || null
this.length = this.hash.length * 4 + 1 + 1

@@ -27,3 +27,3 @@ this.valueEncoding = enc

Node.prototype[inspect] = function (depth, opts) {
return ((opts && opts.stylize) || defaultStylize)({seq: this.seq, key: this.key, value: this.value, hidden: this.hidden}, 'object')
return ((opts && opts.stylize) || defaultStylize)({seq: this.seq, key: this.key, value: this.value}, 'object')
}

@@ -40,6 +40,17 @@

Node.prototype.final = function () {
if (!this.valueBuffer || this.value !== null) return this
this.value = this.valueEncoding ? this.valueEncoding.decode(this.valueBuffer) : this.valueBuffer
this.valueBuffer = null
return this
}
Node.prototype.preencode = function () {
this.flags = this.hidden ? 1 : 0
if (!this.trieBuffer) this.trieBuffer = trie.encode(this.trie)
if (!this.valueBuffer) this.valueBuffer = ((this.value !== null) && this.valueEncoding) ? this.valueEncoding.encode(this.value) : this.value
}
Node.prototype.encode = function () {
this.flags = this.hidden ? 1 : 0
this.trieBuffer = trie.encode(this.trie)
this.valueBuffer = ((this.value !== null) && this.valueEncoding) ? this.valueEncoding.encode(this.value) : this.value
this.preencode()
return messages.Node.encode(this)

@@ -46,0 +57,0 @@ }

@@ -5,5 +5,5 @@ const Node = require('./node')

function Put (db, key, value, { batch, del, condition = null, hidden = false }, cb) {
function Put (db, key, value, { batch, del, condition = null, hidden = false, valueBuffer = null }, cb) {
this._db = db
this._node = new Node({key, value, hidden}, 0, db.valueEncoding)
this._node = new Node({key, value, hidden, valueBuffer}, 0, db.valueEncoding)
this._callback = cb

@@ -55,3 +55,3 @@ this._release = null

if (this._head && this._head.key !== this._node.key) this._head = null
if (this._condition) this._condition(this._head, this._node, oncondition)
if (this._condition) this._condition(this._head && this._head.final(), this._node, oncondition)
else insert()

@@ -58,0 +58,0 @@

{
"name": "hypertrie",
"version": "3.4.0",
"version": "3.4.1",
"description": "Distributed single writer key/value store",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -120,3 +120,2 @@ const tape = require('tape')

db.get('a', { hidden: true }, function (err, node) {
console.log(node)
t.error(err, 'no error')

@@ -123,0 +122,0 @@ t.same(node, null)

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