rocksdb-native 2.4.4 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/batch.js +9 -1
  2. package/package.json +1 -1
package/lib/batch.js CHANGED
@@ -17,6 +17,7 @@ class RocksDBBatch {
17
17
  db._incRef()
18
18
 
19
19
  this._db = db
20
+ this._destroyed = false
20
21
  this._capacity = capacity
21
22
  this._operations = []
22
23
  this._promises = []
@@ -42,7 +43,7 @@ class RocksDBBatch {
42
43
  this._promises = []
43
44
  this._request = null
44
45
  this._resolveRequest = null
45
- this._db._decRef()
46
+ this.destroy()
46
47
 
47
48
  if (resolve !== null) resolve()
48
49
  }
@@ -65,6 +66,13 @@ class RocksDBBatch {
65
66
  this._init()
66
67
  }
67
68
 
69
+ destroy () {
70
+ if (this._request) throw new Error('Batch already flushed')
71
+ if (this._destroyed) return
72
+ this._destroyed = true
73
+ this._db._decRef()
74
+ }
75
+
68
76
  flush () {
69
77
  if (this._request) throw new Error('Request already in progress')
70
78
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rocksdb-native",
3
- "version": "2.4.4",
3
+ "version": "2.5.0",
4
4
  "description": "librocksdb bindings for JavaScript",
5
5
  "exports": {
6
6
  ".": "./index.js",