Skip to content

Commit f1bdb49

Browse files
committed
Create framework for hyperkv
1 parent cdeb6fc commit f1bdb49

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

index.js

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,49 @@
11
var level = require('level')
2-
var hypercore = require('hypercore')
3-
var createImportPipeline = require('./lib/import.js')
2+
3+
var hyperkv = require('hyperkv')
4+
var hyperlog = require('hyperlog')
5+
var sub = require('subleveldown')
6+
7+
// var createImportPipeline = require('./lib/import.js')
8+
var addRow = require('./lib/add.js')
9+
var deleteRow = require('./lib/delete.js')
410

511
module.exports = Jawn
612

713
function Jawn (opts) {
814
if (!opts) opts = {}
9-
this.core = initializeHypercore(opts)
15+
this.core = initializeHyperkv(opts)
1016
this.db = this.core.db
1117
}
1218

19+
/*
1320
Jawn.prototype.createImportPipeline = function (opts) {
1421
return createImportPipeline(this, opts)
1522
}
23+
*/
24+
25+
Jawn.prototype.addRow = function (value, key) {
26+
return addRow(this, value, key)
27+
}
28+
29+
Jawn.prototype.deleteRow = function (key) {
30+
return deleteRow(this, key)
31+
}
1632

1733
// Initializes hypercore and its database
1834
// @default Creates a leveldb database called `data.jawn` and initializes hypercore using that db
1935
// @option 'core' the hypercore instance to use
2036
// @option 'db' the db instace (leveldb) to initialize hypercore with. This is ignored if you use the `core` option
21-
function initializeHypercore (opts) {
37+
function initializeHyperkv (opts) {
2238
var core
2339
if (opts.hasOwnProperty('core')) {
2440
core = opts.core
2541
} else {
2642
var db = opts.db || level('data.jawn')
27-
core = hypercore(db)
43+
core = hyperkv({
44+
log: hyperlog(sub(db, 'log'), { valueEncoding: 'json' }),
45+
db: sub(db, 'kv')
46+
})
2847
}
2948
return core
3049
}

lib/add.js

Whitespace-only changes.

lib/delete.js

Whitespace-only changes.

0 commit comments

Comments
 (0)