rocksdb-native 3.9.0 → 3.9.2

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/index.js CHANGED
@@ -213,6 +213,5 @@ exports.BloomFilterPolicy = BloomFilterPolicy
213
213
  exports.RibbonFilterPolicy = RibbonFilterPolicy
214
214
 
215
215
  function maybeClosed(db) {
216
- if (db._state.closing || db._index === -1)
217
- throw new Error('RocksDB session is closed')
216
+ if (db._state.closing || db._index === -1) throw new Error('RocksDB session is closed')
218
217
  }
package/lib/batch.js CHANGED
@@ -224,9 +224,7 @@ exports.ReadBatch = class RocksDBReadBatch extends RocksDBBatch {
224
224
 
225
225
  promise.reject(new Error(err))
226
226
  } else {
227
- promise.resolve(
228
- values[i] ? this._decodeValue(Buffer.from(values[i])) : null
229
- )
227
+ promise.resolve(values[i] ? this._decodeValue(Buffer.from(values[i])) : null)
230
228
  }
231
229
  }
232
230
 
@@ -238,9 +236,7 @@ exports.ReadBatch = class RocksDBReadBatch extends RocksDBBatch {
238
236
 
239
237
  const promise = new Promise(this._enqueuePromise)
240
238
 
241
- this._operations.push(
242
- new RocksDBGet(this._encodeKey(key), this._db._columnFamily)
243
- )
239
+ this._operations.push(new RocksDBGet(this._encodeKey(key), this._db._columnFamily))
244
240
 
245
241
  this._resize()
246
242
 
@@ -270,13 +266,7 @@ exports.WriteBatch = class RocksDBWriteBatch extends RocksDBBatch {
270
266
  if (this._destroyed) return
271
267
 
272
268
  try {
273
- binding.write(
274
- this._db._state._handle,
275
- this._handle,
276
- this._operations,
277
- this,
278
- this._onwrite
279
- )
269
+ binding.write(this._db._state._handle, this._handle, this._operations, this, this._onwrite)
280
270
  } catch (err) {
281
271
  this._db._state.io.dec()
282
272
  throw err
@@ -308,11 +298,7 @@ exports.WriteBatch = class RocksDBWriteBatch extends RocksDBBatch {
308
298
  const promise = new Promise(this._enqueuePromise)
309
299
 
310
300
  this._operations.push(
311
- new RocksDBPut(
312
- this._encodeKey(key),
313
- this._encodeValue(value),
314
- this._db._columnFamily
315
- )
301
+ new RocksDBPut(this._encodeKey(key), this._encodeValue(value), this._db._columnFamily)
316
302
  )
317
303
 
318
304
  this._resize()
@@ -324,11 +310,7 @@ exports.WriteBatch = class RocksDBWriteBatch extends RocksDBBatch {
324
310
  if (this._request) throw new Error('Request already in progress')
325
311
 
326
312
  this._operations.push(
327
- new RocksDBPut(
328
- this._encodeKey(key),
329
- this._encodeValue(value),
330
- this._db._columnFamily
331
- )
313
+ new RocksDBPut(this._encodeKey(key), this._encodeValue(value), this._db._columnFamily)
332
314
  )
333
315
 
334
316
  this._promises.push(null)
@@ -341,9 +323,7 @@ exports.WriteBatch = class RocksDBWriteBatch extends RocksDBBatch {
341
323
 
342
324
  const promise = new Promise(this._enqueuePromise)
343
325
 
344
- this._operations.push(
345
- new RocksDBDelete(this._encodeKey(key), this._db._columnFamily)
346
- )
326
+ this._operations.push(new RocksDBDelete(this._encodeKey(key), this._db._columnFamily))
347
327
 
348
328
  this._resize()
349
329
 
@@ -353,9 +333,7 @@ exports.WriteBatch = class RocksDBWriteBatch extends RocksDBBatch {
353
333
  tryDelete(key) {
354
334
  if (this._request) throw new Error('Request already in progress')
355
335
 
356
- this._operations.push(
357
- new RocksDBDelete(this._encodeKey(key), this._db._columnFamily)
358
- )
336
+ this._operations.push(new RocksDBDelete(this._encodeKey(key), this._db._columnFamily))
359
337
 
360
338
  this._promises.push(null)
361
339
 
@@ -368,11 +346,7 @@ exports.WriteBatch = class RocksDBWriteBatch extends RocksDBBatch {
368
346
  const promise = new Promise(this._enqueuePromise)
369
347
 
370
348
  this._operations.push(
371
- new RocksDBDeleteRange(
372
- this._encodeKey(start),
373
- this._encodeKey(end),
374
- this._db._columnFamily
375
- )
349
+ new RocksDBDeleteRange(this._encodeKey(start), this._encodeKey(end), this._db._columnFamily)
376
350
  )
377
351
 
378
352
  this._resize()
@@ -384,11 +358,7 @@ exports.WriteBatch = class RocksDBWriteBatch extends RocksDBBatch {
384
358
  if (this._request) throw new Error('Request already in progress')
385
359
 
386
360
  this._operations.push(
387
- new RocksDBDeleteRange(
388
- this._encodeKey(start),
389
- this._encodeKey(end),
390
- this._db._columnFamily
391
- )
361
+ new RocksDBDeleteRange(this._encodeKey(start), this._encodeKey(end), this._db._columnFamily)
392
362
  )
393
363
 
394
364
  this._promises.push(null)
package/lib/iterator.js CHANGED
@@ -186,21 +186,18 @@ module.exports = class RocksDBIterator extends Readable {
186
186
  }
187
187
 
188
188
  _encodeKey(k) {
189
- if (this._db._keyEncoding !== null)
190
- return c.encode(this._db._keyEncoding, k)
189
+ if (this._db._keyEncoding !== null) return c.encode(this._db._keyEncoding, k)
191
190
  if (typeof k === 'string') return Buffer.from(k)
192
191
  return k
193
192
  }
194
193
 
195
194
  _decodeKey(b) {
196
- if (this._db._keyEncoding !== null)
197
- return c.decode(this._db._keyEncoding, b)
195
+ if (this._db._keyEncoding !== null) return c.decode(this._db._keyEncoding, b)
198
196
  return b
199
197
  }
200
198
 
201
199
  _decodeValue(b) {
202
- if (this._db._valueEncoding !== null)
203
- return c.decode(this._db._valueEncoding, b)
200
+ if (this._db._valueEncoding !== null) return c.decode(this._db._valueEncoding, b)
204
201
  return b
205
202
  }
206
203
  }
package/lib/state.js CHANGED
@@ -49,9 +49,7 @@ module.exports = class RocksDBState extends ReadyResource {
49
49
 
50
50
  for (const columnFamily of columnFamilies) {
51
51
  this.columnFamilies.push(
52
- typeof columnFamily === 'string'
53
- ? new ColumnFamily(columnFamily, opts)
54
- : columnFamily
52
+ typeof columnFamily === 'string' ? new ColumnFamily(columnFamily, opts) : columnFamily
55
53
  )
56
54
  }
57
55
 
@@ -222,12 +220,7 @@ module.exports = class RocksDBState extends ReadyResource {
222
220
  })
223
221
 
224
222
  try {
225
- req.handle = binding.flush(
226
- this._handle,
227
- db._columnFamily._handle,
228
- req,
229
- onflush
230
- )
223
+ req.handle = binding.flush(this._handle, db._columnFamily._handle, req, onflush)
231
224
 
232
225
  await promise
233
226
  } finally {
@@ -327,7 +320,10 @@ module.exports = class RocksDBState extends ReadyResource {
327
320
 
328
321
  const { exclusive = false } = opts
329
322
 
330
- const req = { resolve: null, reject: null, handle: null }
323
+ start = this._encodeKey(start)
324
+ end = this._encodeKey(end)
325
+
326
+ const req = { resolve: null, reject: null, handle: null, start, end }
331
327
 
332
328
  const promise = new Promise((resolve, reject) => {
333
329
  req.resolve = resolve
@@ -338,8 +334,8 @@ module.exports = class RocksDBState extends ReadyResource {
338
334
  req.handle = binding.compactRange(
339
335
  this._handle,
340
336
  db._columnFamily._handle,
341
- this._encodeKey(start),
342
- this._encodeKey(end),
337
+ start,
338
+ end,
343
339
  exclusive,
344
340
  req,
345
341
  oncompactrange
@@ -361,13 +357,12 @@ module.exports = class RocksDBState extends ReadyResource {
361
357
 
362
358
  this.io.inc()
363
359
 
364
- const {
365
- includeMemtables = false,
366
- includeFiles = true,
367
- filesSizeErrorMargin = -1
368
- } = opts
360
+ const { includeMemtables = false, includeFiles = true, filesSizeErrorMargin = -1 } = opts
369
361
 
370
- const req = { resolve: null, reject: null, handle: null }
362
+ start = this._encodeKey(start)
363
+ end = this._encodeKey(end)
364
+
365
+ const req = { resolve: null, reject: null, handle: null, start, end }
371
366
 
372
367
  const promise = new Promise((resolve, reject) => {
373
368
  req.resolve = resolve
@@ -378,8 +373,8 @@ module.exports = class RocksDBState extends ReadyResource {
378
373
  req.handle = binding.approximateSize(
379
374
  this._handle,
380
375
  db._columnFamily._handle,
381
- this._encodeKey(start),
382
- this._encodeKey(end),
376
+ start,
377
+ end,
383
378
  includeMemtables,
384
379
  includeFiles,
385
380
  filesSizeErrorMargin,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rocksdb-native",
3
- "version": "3.9.0",
3
+ "version": "3.9.2",
4
4
  "description": "librocksdb bindings for JavaScript",
5
5
  "exports": {
6
6
  ".": "./index.js",
@@ -17,10 +17,11 @@
17
17
  ],
18
18
  "addon": true,
19
19
  "scripts": {
20
+ "format": "prettier --write .",
21
+ "lint": "prettier --check .",
20
22
  "test": "npm run lint && npm run test:bare && npm run test:node",
21
23
  "test:bare": "bare test.js",
22
- "test:node": "node test.js",
23
- "lint": "prettier . --check"
24
+ "test:node": "node test.js"
24
25
  },
25
26
  "repository": {
26
27
  "type": "git",
@@ -50,7 +51,7 @@
50
51
  "cmake-bare": "^1.1.14",
51
52
  "cmake-fetch": "^1.0.1",
52
53
  "cmake-napi": "^1.0.6",
53
- "prettier": "^3.4.1",
54
- "prettier-config-standard": "^7.0.0"
54
+ "prettier": "^3.6.2",
55
+ "prettier-config-holepunch": "^2.0.0"
55
56
  }
56
57
  }