rocksdb-native 3.1.3 → 3.1.5

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/CMakeLists.txt CHANGED
@@ -7,7 +7,7 @@ find_package(cmake-npm REQUIRED PATHS node_modules/cmake-npm)
7
7
 
8
8
  project(rocksdb_native C CXX)
9
9
 
10
- fetch_package("github:holepunchto/librocksdb#caeaa2b")
10
+ fetch_package("github:holepunchto/librocksdb#fb2c47a")
11
11
 
12
12
  add_bare_module(rocksdb_native_bare)
13
13
 
package/binding.c CHANGED
@@ -3,8 +3,8 @@
3
3
  #include <js.h>
4
4
  #include <rocksdb.h>
5
5
  #include <stdlib.h>
6
- #include <utf.h>
7
6
  #include <string.h>
7
+ #include <utf.h>
8
8
 
9
9
  typedef struct {
10
10
  uint32_t low;
@@ -1050,7 +1050,7 @@ rocksdb_native_try_create_external_arraybuffer(js_env_t *env, void *data, size_t
1050
1050
  int err = js_create_external_arraybuffer(env, data, len, rocksdb_native__on_free, NULL, result);
1051
1051
  if (err == 0) return 0;
1052
1052
 
1053
- void* cpy;
1053
+ void *cpy;
1054
1054
  err = js_create_arraybuffer(env, len, &cpy, result);
1055
1055
  if (err != 0) return err;
1056
1056
 
@@ -1282,8 +1282,13 @@ rocksdb_native__on_read(rocksdb_read_batch_t *handle, int status) {
1282
1282
  } else {
1283
1283
  rocksdb_slice_t *slice = &req->reads[i].value;
1284
1284
 
1285
- err = rocksdb_native_try_create_external_arraybuffer(env, (void *) slice->data, slice->len, &result);
1286
- assert(err == 0);
1285
+ if (slice->data == NULL && slice->len == (size_t) -1) {
1286
+ err = js_get_null(env, &result);
1287
+ assert(err == 0);
1288
+ } else {
1289
+ err = rocksdb_native_try_create_external_arraybuffer(env, (void *) slice->data, slice->len, &result);
1290
+ assert(err == 0);
1291
+ }
1287
1292
 
1288
1293
  err = js_set_element(env, values, i, result);
1289
1294
  assert(err == 0);
package/index.js CHANGED
@@ -80,9 +80,8 @@ class RocksDB {
80
80
  if (this._index !== -1) this._state.removeSession(this)
81
81
 
82
82
  if (force) {
83
- for (let i = this._state.sessions.length - 1; i >= 0; i--) {
84
- await this._state.sessions[i].close()
85
- }
83
+ while (this._state.sessions.length > 0)
84
+ await this._state.sessions[this._state.sessions.length - 1].close()
86
85
  }
87
86
 
88
87
  return this.isRoot() ? this._state.close() : Promise.resolve()
package/lib/batch.js CHANGED
@@ -173,12 +173,11 @@ exports.ReadBatch = class RocksDBReadBatch extends RocksDBBatch {
173
173
  const err = errs[i]
174
174
 
175
175
  if (err) promise.reject(new Error(err))
176
- else
176
+ else {
177
177
  promise.resolve(
178
- values[i].byteLength === 0
179
- ? null
180
- : this._decodeValue(Buffer.from(values[i]))
178
+ values[i] ? this._decodeValue(Buffer.from(values[i])) : null
181
179
  )
180
+ }
182
181
  }
183
182
 
184
183
  this._onfinished()
package/lib/state.js CHANGED
@@ -150,8 +150,9 @@ module.exports = class DBState extends ReadyResource {
150
150
 
151
151
  async _close() {
152
152
  while (!this.activity.isIdle()) await this.activity.idle()
153
- for (let i = this.sessions.length - 1; i >= 0; i--)
154
- await this.sessions[i].close()
153
+
154
+ while (this.sessions.length > 0)
155
+ await this.sessions[this.sessions.length - 1].close()
155
156
 
156
157
  for (const columnFamily of this.columnFamilies) columnFamily.destroy()
157
158
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rocksdb-native",
3
- "version": "3.1.3",
3
+ "version": "3.1.5",
4
4
  "description": "librocksdb bindings for JavaScript",
5
5
  "exports": {
6
6
  ".": "./index.js",