File tree 1 file changed +16
-2
lines changed
1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -6,11 +6,25 @@ module.exports = Jawn
6
6
7
7
function Jawn ( opts ) {
8
8
if ( ! opts ) opts = { }
9
- var db = opts . db || level ( 'data.jawn' )
10
- this . core = opts . core || hypercore ( db )
9
+ this . core = initializeHypercore ( opts )
11
10
this . db = this . core . db
12
11
}
13
12
14
13
Jawn . prototype . createImportPipeline = function ( opts ) {
15
14
return createImportPipeline ( this , opts )
16
15
}
16
+
17
+ // Initializes hypercore and its database
18
+ // @default Creates a leveldb database called `data.jawn` and initializes hypercore using that db
19
+ // @option 'core' the hypercore instance to use
20
+ // @option 'db' the db instace (leveldb) to initialize hypercore with. This is ignored if you use the `core` option
21
+ function initializeHypercore ( opts ) {
22
+ var core
23
+ if ( opts . hasOwnProperty ( 'core' ) ) {
24
+ core = opts . core
25
+ } else {
26
+ var db = opts . db || level ( 'data.jawn' )
27
+ core = hypercore ( db )
28
+ }
29
+ return core
30
+ }
You can’t perform that action at this time.
0 commit comments