level-sublevel
Advanced tools
Comparing version 4.8.3 to 5.0.0
@@ -8,3 +8,7 @@ var EventEmitter = require('events').EventEmitter | ||
module.exports = function (db, options) { | ||
module.exports = function (_db, options) { | ||
function DB () {} | ||
DB.prototype = _db | ||
var db = new DB() | ||
if (db.sublevel) return db | ||
@@ -11,0 +15,0 @@ |
{ | ||
"name": "level-sublevel", | ||
"description": "partition levelup databases", | ||
"version": "4.8.3", | ||
"version": "5.0.0", | ||
"homepage": "https://github.com/dominictarr/level-sublevel", | ||
@@ -6,0 +6,0 @@ "repository": { |
@@ -21,9 +21,11 @@ var test = require('tape') | ||
test('sublevel - batch', function (t) { | ||
var sublevel = require('../') | ||
function sl(name) { | ||
return sublevel(level(name), {sep: "~"}) | ||
} | ||
var base = level('test-sublevel') | ||
var Sublevel = require('../') | ||
test('sublevel - batch', function (t) { | ||
Sublevel(base, { sep: '~' }) | ||
var base = sl('test-sublevel') | ||
@@ -59,8 +61,4 @@ var a = base.sublevel('A') | ||
var base = level('test-sublevel2') | ||
var base = sl('test-sublevel2') | ||
var Sublevel = require('../') | ||
Sublevel(base, { sep: '~' }) | ||
var a = base.sublevel('A') | ||
@@ -92,8 +90,4 @@ var b = base.sublevel('B') | ||
var base = level('test-sublevel3') | ||
var base = sl('test-sublevel3') | ||
var Sublevel = require('../') | ||
Sublevel(base, { sep: '~' }) | ||
var a = base.sublevel('A') | ||
@@ -125,8 +119,4 @@ var b = base.sublevel('B') | ||
var base = level('test-sublevel4') | ||
var base = sl('test-sublevel4') | ||
var Sublevel = require('../') | ||
Sublevel(base, { sep: '~' }) | ||
var a = base.sublevel('A') | ||
@@ -133,0 +123,0 @@ var b = base.sublevel('B') |
var level = require('level-test')() | ||
var Sublevel = require('../') | ||
function sl (name) { | ||
return Sublevel(level(name), {sep: '~'}) | ||
} | ||
require('tape')('sublevel', function (t) { | ||
var base = level('test-sublevel') | ||
var Sublevel = require('../') | ||
var base = sl('test-sublevel') | ||
Sublevel(base, { sep: '~' }) | ||
var a = base.sublevel('A') | ||
@@ -11,0 +13,0 @@ var b = base.sublevel('SEQ') |
@@ -7,6 +7,3 @@ | ||
var level = require('level-test')() | ||
var sublevel = require('../') | ||
var tape = require('tape') | ||
@@ -13,0 +10,0 @@ |
var level = require('level-test')() | ||
var Sublevel = require('../') | ||
function sl (name) { | ||
return Sublevel(level(name), { sep: '~' }) | ||
} | ||
require('tape')('sublevel', function (t) { | ||
var base = level('test-sublevel', function () { | ||
var Sublevel = require('../') | ||
var base = sl('test-sublevel') | ||
Sublevel(base, { sep: '~' }) | ||
var a = base.sublevel('A') | ||
var a_a = a.sublevel('A') | ||
var a = base.sublevel('A') | ||
var a_a = a.sublevel('A') | ||
var as = {} | ||
var aas = {} | ||
var as = {} | ||
var aas = {} | ||
a.pre(function (e) { | ||
as[e.key] = e.value | ||
console.log('A :', e) | ||
}) | ||
a.pre(function (e) { | ||
as[e.key] = e.value | ||
console.log('A :', e) | ||
}) | ||
a_a.pre(function (e) { | ||
aas[e.key] = e.value | ||
console.log('A_A :', e) | ||
}) | ||
a_a.pre(function (e) { | ||
aas[e.key] = e.value | ||
console.log('A_A :', e) | ||
}) | ||
var n = 3 | ||
a.put('apple', '1', next) | ||
a.put('banana', '2', next) | ||
var n = 3 | ||
a.put('apple', '1', next) | ||
a.put('banana', '2', next) | ||
a_a.put('aardvark', 'animal1', next) | ||
a_a.put('aardvark', 'animal1', next) | ||
function next() { | ||
if(--n) return | ||
t.deepEqual(as, {apple: '1', banana: '2'}) | ||
t.deepEqual(aas, {aardvark: 'animal1'}) | ||
t.end() | ||
} | ||
function next() { | ||
if(--n) return | ||
t.deepEqual(as, {apple: '1', banana: '2'}) | ||
t.deepEqual(aas, {aardvark: 'animal1'}) | ||
t.end() | ||
} | ||
function all(db, cb) { | ||
var o = {} | ||
db.createReadStream().on('data', function (data) { | ||
o[data.key.toString()] = data.value.toString() | ||
}) | ||
.on('end', function () { | ||
cb(null, o) | ||
}) | ||
.on('error', cb) | ||
} | ||
}) | ||
function all(db, cb) { | ||
var o = {} | ||
db.createReadStream().on('data', function (data) { | ||
o[data.key.toString()] = data.value.toString() | ||
}) | ||
.on('end', function () { | ||
cb(null, o) | ||
}) | ||
.on('error', cb) | ||
} | ||
}) |
var level = require('level-test')() | ||
var sublevel = require('../') | ||
function sl (name) { | ||
return sublevel(level(name), {sep: '~'}) | ||
} | ||
require('tape')('sublevel', function (t) { | ||
@@ -7,48 +12,44 @@ | ||
var base = level('test-sublevel-readstream', function () { | ||
var Sublevel = require('../') | ||
var base = sl('test-sublevel-readstream') | ||
Sublevel(base, { sep: '~' }) | ||
var a = base.sublevel('A') | ||
var a = base.sublevel('A') | ||
var i = 0 | ||
var i = 0 | ||
function all(db, cb) { | ||
var o = {} | ||
db.createReadStream({end: '\xff\xff'}).on('data', function (data) { | ||
o[data.key.toString()] = data.value.toString() | ||
}) | ||
.on('end', function () { | ||
cb(null, o) | ||
}) | ||
.on('error', cb) | ||
} | ||
function all(db, cb) { | ||
var o = {} | ||
db.createReadStream({end: '\xff\xff'}).on('data', function (data) { | ||
o[data.key.toString()] = data.value.toString() | ||
}) | ||
.on('end', function () { | ||
cb(null, o) | ||
}) | ||
.on('error', cb) | ||
} | ||
var _a, _b, _c | ||
var _a, _b, _c | ||
var as = a.createWriteStream() | ||
as.write({key: 'a', value: _a ='AAA_'+Math.random()}) | ||
as.write({key: 'b', value: _b = 'BBB_'+Math.random()}) | ||
as.write({key: 'c', value: _c = 'CCC_'+Math.random()}) | ||
as.end() | ||
as.on('close', function () { | ||
var as = a.createWriteStream() | ||
as.write({key: 'a', value: _a ='AAA_'+Math.random()}) | ||
as.write({key: 'b', value: _b = 'BBB_'+Math.random()}) | ||
as.write({key: 'c', value: _c = 'CCC_'+Math.random()}) | ||
as.end() | ||
as.on('close', function () { | ||
all(base, function (err, obj) { | ||
console.log(obj) | ||
t.deepEqual(obj, | ||
{ '~A~a': _a, | ||
'~A~b': _b, | ||
'~A~c': _c | ||
}) | ||
all(base, function (err, obj) { | ||
all(a, function (err, obj) { | ||
console.log(obj) | ||
t.deepEqual(obj, | ||
{ '~A~a': _a, | ||
'~A~b': _b, | ||
'~A~c': _c | ||
{ 'a': _a, | ||
'b': _b, | ||
'c': _c | ||
}) | ||
all(a, function (err, obj) { | ||
console.log(obj) | ||
t.deepEqual(obj, | ||
{ 'a': _a, | ||
'b': _b, | ||
'c': _c | ||
}) | ||
t.end() | ||
}) | ||
t.end() | ||
}) | ||
@@ -55,0 +56,0 @@ }) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1335
46168