@nxtedition/rocksdb 15.4.0 → 15.4.1
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.
- package/binding.cc +0 -4
- package/cache.js +1 -1
- package/chained-batch.js +12 -3
- package/index.js +11 -2
- package/iterator.js +13 -5
- package/package.json +1 -1
- package/prebuilds/darwin-arm64/@nxtedition+rocksdb.node +0 -0
- package/prebuilds/linux-x64/@nxtedition+rocksdb.node +0 -0
package/binding.cc
CHANGED
package/cache.js
CHANGED
package/chained-batch.js
CHANGED
|
@@ -23,6 +23,10 @@ class ChainedBatch extends AbstractChainedBatch {
|
|
|
23
23
|
this[kBusy] = false
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
[Symbol.asyncDispose] () {
|
|
27
|
+
return this.close()
|
|
28
|
+
}
|
|
29
|
+
|
|
26
30
|
get length () {
|
|
27
31
|
assert(this[kBatchContext])
|
|
28
32
|
|
|
@@ -109,10 +113,15 @@ class ChainedBatch extends AbstractChainedBatch {
|
|
|
109
113
|
callback = fromCallback(callback, kPromise)
|
|
110
114
|
|
|
111
115
|
this[kBusy] = true
|
|
112
|
-
|
|
116
|
+
try {
|
|
117
|
+
binding.batch_write(this[kDbContext], this[kBatchContext], options ?? EMPTY, (err) => {
|
|
118
|
+
this[kBusy] = false
|
|
119
|
+
callback(err)
|
|
120
|
+
})
|
|
121
|
+
} catch (err) {
|
|
113
122
|
this[kBusy] = false
|
|
114
|
-
callback
|
|
115
|
-
}
|
|
123
|
+
process.nextTick(callback, err)
|
|
124
|
+
}
|
|
116
125
|
|
|
117
126
|
return callback[kPromise]
|
|
118
127
|
}
|
package/index.js
CHANGED
|
@@ -18,7 +18,7 @@ const kPendingClose = Symbol('pendingClose')
|
|
|
18
18
|
|
|
19
19
|
const { kRef, kUnref } = require('./util')
|
|
20
20
|
|
|
21
|
-
const kEmpty = {}
|
|
21
|
+
const kEmpty = Object.freeze({})
|
|
22
22
|
|
|
23
23
|
class RocksLevel extends AbstractLevel {
|
|
24
24
|
constructor (locationOrHandle, { ...options } = {}) {
|
|
@@ -41,6 +41,10 @@ class RocksLevel extends AbstractLevel {
|
|
|
41
41
|
this[kPendingClose] = null
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
[Symbol.asyncDispose] () {
|
|
45
|
+
return this.close()
|
|
46
|
+
}
|
|
47
|
+
|
|
44
48
|
static async open (...args) {
|
|
45
49
|
const db = new this(...args)
|
|
46
50
|
await db.open()
|
|
@@ -90,7 +94,7 @@ class RocksLevel extends AbstractLevel {
|
|
|
90
94
|
|
|
91
95
|
if (options.createIfMissing) {
|
|
92
96
|
fs.mkdir(this.location, { recursive: true }, (err) => {
|
|
93
|
-
if (err) {
|
|
97
|
+
if (err && err.code !== 'EEXIST') {
|
|
94
98
|
callback(err)
|
|
95
99
|
} else {
|
|
96
100
|
doOpen()
|
|
@@ -157,6 +161,10 @@ class RocksLevel extends AbstractLevel {
|
|
|
157
161
|
}
|
|
158
162
|
|
|
159
163
|
_getManyAsync (keys, options, callback) {
|
|
164
|
+
if (keys.some(key => typeof key === 'string')) {
|
|
165
|
+
keys = keys.map(key => typeof key === 'string' ? Buffer.from(key) : key)
|
|
166
|
+
}
|
|
167
|
+
|
|
160
168
|
callback = fromCallback(callback, kPromise)
|
|
161
169
|
|
|
162
170
|
try {
|
|
@@ -170,6 +178,7 @@ class RocksLevel extends AbstractLevel {
|
|
|
170
178
|
}
|
|
171
179
|
})
|
|
172
180
|
} catch (err) {
|
|
181
|
+
this[kUnref]()
|
|
173
182
|
process.nextTick(callback, err)
|
|
174
183
|
}
|
|
175
184
|
|
package/iterator.js
CHANGED
|
@@ -16,7 +16,7 @@ const kFirst = Symbol('first')
|
|
|
16
16
|
const kPosition = Symbol('position')
|
|
17
17
|
const kBusy = Symbol('busy')
|
|
18
18
|
|
|
19
|
-
const kEmpty = []
|
|
19
|
+
const kEmpty = Object.freeze([])
|
|
20
20
|
|
|
21
21
|
class Iterator extends AbstractIterator {
|
|
22
22
|
constructor (db, context, options) {
|
|
@@ -32,6 +32,10 @@ class Iterator extends AbstractIterator {
|
|
|
32
32
|
this[kBusy] = false
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
[Symbol.asyncDispose] () {
|
|
36
|
+
return this.close()
|
|
37
|
+
}
|
|
38
|
+
|
|
35
39
|
_seek (target) {
|
|
36
40
|
this._seekSync(target)
|
|
37
41
|
}
|
|
@@ -132,6 +136,8 @@ class Iterator extends AbstractIterator {
|
|
|
132
136
|
this[kPosition] = 0
|
|
133
137
|
|
|
134
138
|
try {
|
|
139
|
+
this[kDB][kRef]()
|
|
140
|
+
this[kBusy] = true
|
|
135
141
|
binding.iterator_seek(this[kContext], target, (err) => {
|
|
136
142
|
this[kBusy] = false
|
|
137
143
|
this[kDB][kUnref]()
|
|
@@ -142,9 +148,9 @@ class Iterator extends AbstractIterator {
|
|
|
142
148
|
callback(null)
|
|
143
149
|
}
|
|
144
150
|
})
|
|
145
|
-
this[kDB][kRef]()
|
|
146
|
-
this[kBusy] = true
|
|
147
151
|
} catch (err) {
|
|
152
|
+
this[kBusy] = false
|
|
153
|
+
this[kDB][kUnref]()
|
|
148
154
|
process.nextTick(callback, err)
|
|
149
155
|
}
|
|
150
156
|
|
|
@@ -175,6 +181,8 @@ class Iterator extends AbstractIterator {
|
|
|
175
181
|
if (this[kFinished]) {
|
|
176
182
|
process.nextTick(callback, null, { rows: [], finished: true })
|
|
177
183
|
} else {
|
|
184
|
+
this[kDB][kRef]()
|
|
185
|
+
this[kBusy] = true
|
|
178
186
|
binding.iterator_nextv(this[kContext], size, options, (err, result) => {
|
|
179
187
|
this[kBusy] = false
|
|
180
188
|
this[kDB][kUnref]()
|
|
@@ -186,10 +194,10 @@ class Iterator extends AbstractIterator {
|
|
|
186
194
|
callback(null, result)
|
|
187
195
|
}
|
|
188
196
|
})
|
|
189
|
-
this[kBusy] = true
|
|
190
|
-
this[kDB][kRef]()
|
|
191
197
|
}
|
|
192
198
|
} catch (err) {
|
|
199
|
+
this[kBusy] = false
|
|
200
|
+
this[kDB][kUnref]()
|
|
193
201
|
process.nextTick(callback, err)
|
|
194
202
|
}
|
|
195
203
|
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|