fake-indexeddb 5.0.1 → 5.0.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.
@@ -178,12 +178,7 @@ class FDBIndex {
178
178
  }
179
179
  return this.objectStore.transaction._execRequestAsync({
180
180
  operation: () => {
181
- let count = 0;
182
- const cursor = new _FDBCursor.default(this, key);
183
- while (cursor._iterate() !== null) {
184
- count += 1;
185
- }
186
- return count;
181
+ return this._rawIndex.count(key);
187
182
  },
188
183
  source: this
189
184
  });
@@ -370,12 +370,7 @@ class FDBObjectStore {
370
370
  }
371
371
  return this.transaction._execRequestAsync({
372
372
  operation: () => {
373
- let count = 0;
374
- const cursor = new _FDBCursor.default(this, key);
375
- while (cursor._iterate() !== null) {
376
- count += 1;
377
- }
378
- return count;
373
+ return this._rawObjectStore.count(key);
379
374
  },
380
375
  source: this
381
376
  });
@@ -150,6 +150,15 @@ class Index {
150
150
  source: null
151
151
  });
152
152
  }
153
+ count(range) {
154
+ let count = 0;
155
+
156
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
157
+ for (const record of this.records.values(range)) {
158
+ count += 1;
159
+ }
160
+ return count;
161
+ }
153
162
  }
154
163
  var _default = exports.default = Index;
155
164
  module.exports = exports.default;
@@ -166,6 +166,15 @@ class ObjectStore {
166
166
  rawIndex.records.clear();
167
167
  }
168
168
  }
169
+ count(range) {
170
+ let count = 0;
171
+
172
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
173
+ for (const record of this.records.values(range)) {
174
+ count += 1;
175
+ }
176
+ return count;
177
+ }
169
178
  }
170
179
  var _default = exports.default = ObjectStore;
171
180
  module.exports = exports.default;
@@ -171,12 +171,7 @@ class FDBIndex {
171
171
  }
172
172
  return this.objectStore.transaction._execRequestAsync({
173
173
  operation: () => {
174
- let count = 0;
175
- const cursor = new FDBCursor(this, key);
176
- while (cursor._iterate() !== null) {
177
- count += 1;
178
- }
179
- return count;
174
+ return this._rawIndex.count(key);
180
175
  },
181
176
  source: this
182
177
  });
@@ -363,12 +363,7 @@ class FDBObjectStore {
363
363
  }
364
364
  return this.transaction._execRequestAsync({
365
365
  operation: () => {
366
- let count = 0;
367
- const cursor = new FDBCursor(this, key);
368
- while (cursor._iterate() !== null) {
369
- count += 1;
370
- }
371
- return count;
366
+ return this._rawObjectStore.count(key);
372
367
  },
373
368
  source: this
374
369
  });
@@ -144,5 +144,14 @@ class Index {
144
144
  source: null
145
145
  });
146
146
  }
147
+ count(range) {
148
+ let count = 0;
149
+
150
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
151
+ for (const record of this.records.values(range)) {
152
+ count += 1;
153
+ }
154
+ return count;
155
+ }
147
156
  }
148
157
  export default Index;
@@ -159,5 +159,14 @@ class ObjectStore {
159
159
  rawIndex.records.clear();
160
160
  }
161
161
  }
162
+ count(range) {
163
+ let count = 0;
164
+
165
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
166
+ for (const record of this.records.values(range)) {
167
+ count += 1;
168
+ }
169
+ return count;
170
+ }
162
171
  }
163
172
  export default ObjectStore;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fake-indexeddb",
3
- "version": "5.0.1",
3
+ "version": "5.0.2",
4
4
  "description": "Fake IndexedDB: a pure JS in-memory implementation of the IndexedDB API",
5
5
  "homepage": "https://github.com/dumbmatter/fakeIndexedDB",
6
6
  "repository": {