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

level-sublevel

Package Overview
Dependencies
Maintainers
1
Versions
102
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

level-sublevel - npm Package Compare versions

Comparing version 4.4.0 to 4.5.0

6

index.js

@@ -20,2 +20,4 @@ var EventEmitter = require('events').EventEmitter

db.sublevel = function (prefix) {
if(db.sublevels[prefix])
return db.sublevels[prefix]
return new SubDb(db, prefix, sep)

@@ -69,4 +71,6 @@ }

if(e.prefix) {
if(e.prefix && 'function' === typeof e.prefix.prefix)
if('function' === typeof e.prefix.prefix)
e.key = e.prefix.prefix(e.key)
else if('string' === typeof e.prefix)
e.key = e.prefix + e.key
}

@@ -73,0 +77,0 @@ })

2

package.json
{
"name": "level-sublevel",
"description": "",
"version": "4.4.0",
"version": "4.5.0",
"homepage": "https://github.com/dominictarr/level-sublevel",

@@ -6,0 +6,0 @@ "repository": {

@@ -41,2 +41,4 @@ var EventEmitter = require('events').EventEmitter

SDB.sublevel = function (prefix) {
if(this.sublevels[prefix])
return this.sublevels[prefix]
return new SubDB(this, prefix, this._sep)

@@ -63,2 +65,7 @@ }

changes.forEach(function (ch) {
//OH YEAH, WE NEED TO VALIDATE THAT UPDATING THIS KEY/PREFIX IS ALLOWED
if('string' === typeof ch.prefix) {
console.log(ch.prefix, ch.key)
ch.key = ch.prefix + ch.key
} else
ch.key = (ch.prefix || self).prefix(ch.key)

@@ -65,0 +72,0 @@ if(ch.prefix) ch.prefix = null

@@ -117,5 +117,47 @@ var test = require('tape')

})
})
test('sublevel - prefixed batches on subsection - strings', function (t) {
require('rimraf').sync('/tmp/test-sublevel4')
var base = require('levelup')('/tmp/test-sublevel4')
var Sublevel = require('../')
Sublevel(base, '~')
var a = base.sublevel('A')
var b = base.sublevel('B')
var b_c = b.sublevel('C')
var obj = {}
a.batch([
{key: 'a', value: 1, type: 'put', prefix: base.prefix()},
{key: 'b', value: 2, type: 'put', prefix: b.prefix()},
{key: 'c', value: 3, type: 'put', prefix: base.prefix()},
{key: 'd', value: 4, type: 'put'},
{key: 'e', value: 5, type: 'put', prefix: base.prefix()},
{key: 'f', value: 6, type: 'put', prefix: b_c.prefix()},
], function (err) {
base.createReadStream({end: '\xff\xff'})
.on('data', function (ch) {
obj[ch.key] = ch.value
})
.on('end', function () {
console.log('D?', obj)
t.deepEqual(obj, {
'a': '1',
'c': '3',
'e': '5',
'~A~d': '4',
'~B~b': '2',
'~B~~C~f': '6'
})
console.log(obj)
t.end()
})
})
})

@@ -17,5 +17,10 @@ require('rimraf').sync('/tmp/test-sublevels')

t.strictEqual(base.sublevel('foo'), foo)
t.strictEqual(base.sublevel('bar'), bar)
var fooBlerg = foo.sublevel('blerg')
t.deepEqual(foo.sublevels, {blerg: fooBlerg})
t.strictEqual(foo.sublevel('blerg'), fooBlerg)
t.end()

@@ -22,0 +27,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