@nxtedition/rocksdb 12.0.3 → 12.0.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/chained-batch.js CHANGED
@@ -83,14 +83,18 @@ class ChainedBatch extends AbstractChainedBatch {
83
83
  }
84
84
 
85
85
  _close (callback) {
86
- assert(this[kBatchContext])
87
-
88
- binding.batch_clear(this[kBatchContext])
89
- this[kBatchContext] = null
86
+ this._closeSync()
90
87
 
91
88
  process.nextTick(callback)
92
89
  }
93
90
 
91
+ _closeSync () {
92
+ if (this[kBatchContext]) {
93
+ binding.batch_clear(this[kBatchContext])
94
+ this[kBatchContext] = null
95
+ }
96
+ }
97
+
94
98
  get length () {
95
99
  assert(this[kBatchContext])
96
100
 
package/index.js CHANGED
@@ -152,10 +152,6 @@ class RocksLevel extends AbstractLevel {
152
152
  }
153
153
 
154
154
  _getMany (keys, options, callback) {
155
- if (keys.some(key => typeof key === 'string')) {
156
- keys = keys.map(key => typeof key === 'string' ? Buffer.from(key) : key)
157
- }
158
-
159
155
  callback = fromCallback(callback, kPromise)
160
156
 
161
157
  try {
package/iterator.js CHANGED
@@ -114,8 +114,6 @@ class Iterator extends AbstractIterator {
114
114
  }
115
115
 
116
116
  _close (callback) {
117
- assert(this[kContext])
118
-
119
117
  try {
120
118
  this._closeSync()
121
119
  process.nextTick(callback)
@@ -125,11 +123,12 @@ class Iterator extends AbstractIterator {
125
123
  }
126
124
 
127
125
  _closeSync () {
128
- assert(this[kContext])
129
-
130
126
  this[kCache] = kEmpty
131
- binding.iterator_close(this[kContext])
132
- this[kContext] = null
127
+
128
+ if (this[kContext]) {
129
+ binding.iterator_close(this[kContext])
130
+ this[kContext] = null
131
+ }
133
132
  }
134
133
 
135
134
  _end (callback) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/rocksdb",
3
- "version": "12.0.3",
3
+ "version": "12.0.5",
4
4
  "description": "A low-level Node.js RocksDB binding",
5
5
  "license": "MIT",
6
6
  "main": "index.js",
package/util.h CHANGED
@@ -133,10 +133,6 @@ static napi_status GetString(napi_env env, napi_value from, std::string& to) {
133
133
  return napi_ok;
134
134
  }
135
135
 
136
- void CleanupString(void* env, void* ref) {
137
- napi_delete_reference(static_cast<napi_env>(env), static_cast<napi_ref>(ref));
138
- }
139
-
140
136
  static napi_status GetString(napi_env env, napi_value from, rocksdb::PinnableSlice& to) {
141
137
  napi_valuetype type;
142
138
  NAPI_STATUS_RETURN(napi_typeof(env, from, &type));
@@ -156,8 +152,7 @@ static napi_status GetString(napi_env env, napi_value from, rocksdb::PinnableSli
156
152
  size_t length = 0;
157
153
  napi_ref ref;
158
154
  NAPI_STATUS_RETURN(napi_get_buffer_info(env, from, reinterpret_cast<void**>(&buf), &length));
159
- NAPI_STATUS_RETURN(napi_create_reference(env, from, 1, &ref));
160
- to.PinSlice(rocksdb::Slice{buf,length}, CleanupString, env, ref);
155
+ to.PinSelf(rocksdb::Slice{buf,length});
161
156
  } else {
162
157
  return napi_invalid_arg;
163
158
  }