Skip to content

Commit 8984b77

Browse files
committed
Change hyperkv back to hypercore temporarily
1 parent eda7381 commit 8984b77

File tree

2 files changed

+12
-21
lines changed

2 files changed

+12
-21
lines changed

index.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,13 @@
1-
var hyperkv = require('hyperkv')
2-
var hyperlog = require('hyperlog')
3-
var sub = require('subleveldown')
41
var level = require('level')
5-
2+
var hypercore = require('hypercore')
63
var createImportPipeline = require('./lib/import.js')
74

85
module.exports = Jawn
96

107
function Jawn (opts) {
118
if (!opts) opts = {}
129
var db = opts.db || level('data.jawn')
13-
var kv = hyperkv({
14-
log: hyperlog(sub(db, 'log'), {valueEncoding: 'json'}),
15-
db: sub(db, 'kv')
16-
})
17-
this.core = opts.core || kv
10+
this.core = opts.core || hypercore(db)
1811
this.db = this.core.db
1912
}
2013

test/hyperkv.js

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ var hyperkv = require('hyperkv')
55
var hyperlog = require('hyperlog')
66
var sub = require('subleveldown')
77
var through = require('through2')
8-
var miss = require('mississippi')
98
var memdb = require('memdb')
109

1110
test('import rows to hyperkv', function (t) {
@@ -15,23 +14,24 @@ test('import rows to hyperkv', function (t) {
1514
db: sub(db, 'kv')
1615
})
1716

18-
var importStream = importFromFile(kv, 'dummy.json')
17+
var hs = kv.createHistoryStream()
18+
importFromFile(kv, 'dummy.json')
1919

2020
var expected = [
2121
'{"foo":"bar","name":"josie","age":"35"}',
2222
'{"foo":"baz","name":"eloise","age":"71"}',
2323
'{"foo":"baz","name":"francoise","age":"5"}'
2424
]
2525

26-
importStream.on('finish', verify)
26+
hs.on('data', verifyBlock)
27+
hs.on('end', countBlocks)
2728

28-
function verify (err) {
29-
if (err) { console.log(err) }
30-
var hs = kv.createHistoryStream('test')
31-
hs.on('data', function (block) {
32-
t.same(block.toString(), expected.shift(), 'blocks matched imported line')
33-
})
29+
function verifyBlock (block) {
30+
t.same(block.toString(), expected.shift(), 'blocks matched imported line')
31+
}
3432

33+
function countBlocks (err) {
34+
if (err) { console.log(err) }
3535
t.end()
3636
}
3737
})
@@ -44,7 +44,7 @@ function importFromFile (kv, file) {
4444
var data = fs.createReadStream(fixture(file))
4545
var tr = through(putData, end)
4646

47-
var importStream = miss.pipeline(data, tr)
47+
data.pipe(tr)
4848

4949
function putData (row, _, next) {
5050
kv.put('test', row.toString())
@@ -54,6 +54,4 @@ function importFromFile (kv, file) {
5454
function end (done) {
5555
done()
5656
}
57-
58-
return importStream
5957
}

0 commit comments

Comments
 (0)