Skip to content
This repository was archived by the owner on Mar 23, 2023. It is now read-only.

Commit b21428c

Browse files
authored
fix: init db in overridable method for easier extending (#21)
Sometimes you might want to pass a fully initialised level instance to the LevelDatastore constructor or use a singleton or something else. Instead of creating the level instance in the constructor this change adds a method that child classes can override to tweak the behaviour as they see fit.
1 parent 7dc7876 commit b21428c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ class LevelDatastore {
1717
database = require('level')
1818
}
1919

20-
this.db = database(path, {
20+
this.db = this._initDb(database, path, opts)
21+
}
22+
23+
_initDb (database, path, opts) {
24+
return database(path, {
2125
...opts,
2226
valueEncoding: 'binary',
2327
compression: false // same default as go

0 commit comments

Comments
 (0)