11var level = require ( 'level' )
2+ var hypercore = require ( 'hypercore' )
23
34var hyperkv = require ( 'hyperkv' )
45var hyperlog = require ( 'hyperlog' )
56var sub = require ( 'subleveldown' )
67
7- // var createImportPipeline = require('./lib/import.js')
8+ var createImportPipeline = require ( './lib/import.js' )
9+ var importRowKv = require ( './lib/importkv.js' )
810var addRow = require ( './lib/add.js' )
911var deleteRow = require ( './lib/delete.js' )
1012
1113module . exports = Jawn
1214
1315function Jawn ( opts ) {
1416 if ( ! opts ) opts = { }
17+ this . core = initializeHypercore ( opts )
1518 this . kv = initializeHyperkv ( opts )
1619 this . db = this . core . db
20+ this . db_kv = this . kv . db
1721}
1822
19- /*
2023Jawn . prototype . createImportPipeline = function ( opts ) {
2124 return createImportPipeline ( this , opts )
2225}
23- */
26+
27+ Jawn . prototype . importRowKv = function ( file ) {
28+ return importRowKv ( this , file )
29+ }
2430
2531Jawn . prototype . addRow = function ( key , value ) {
2632 return addRow ( this , key , value )
@@ -34,6 +40,17 @@ Jawn.prototype.deleteRow = function (key) {
3440// @default Creates a leveldb database called `data.jawn` and initializes hypercore using that db
3541// @option 'core' the hypercore instance to use
3642// @option 'db' the db instace (leveldb) to initialize hypercore with. This is ignored if you use the `core` option
43+ function initializeHypercore ( opts ) {
44+ var core
45+ if ( opts . hasOwnProperty ( 'core' ) ) {
46+ core = opts . core
47+ } else {
48+ var db = opts . db || level ( 'data.jawn' )
49+ core = hypercore ( db )
50+ }
51+ return core
52+ }
53+
3754function initializeHyperkv ( opts ) {
3855 var kv
3956 if ( opts . hasOwnProperty ( 'core' ) ) {
0 commit comments