fake-indexeddb 4.0.2 → 5.0.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.
Files changed (64) hide show
  1. package/README.md +42 -6
  2. package/build/cjs/FDBCursor.js +39 -159
  3. package/build/cjs/FDBCursorWithValue.js +1 -9
  4. package/build/cjs/FDBDatabase.js +9 -72
  5. package/build/cjs/FDBFactory.js +23 -66
  6. package/build/cjs/FDBIndex.js +17 -73
  7. package/build/cjs/FDBKeyRange.js +3 -28
  8. package/build/cjs/FDBObjectStore.js +25 -145
  9. package/build/cjs/FDBOpenDBRequest.js +1 -8
  10. package/build/cjs/FDBRequest.js +1 -15
  11. package/build/cjs/FDBTransaction.js +26 -64
  12. package/build/cjs/FDBVersionChangeEvent.js +1 -8
  13. package/build/cjs/fakeIndexedDB.js +1 -5
  14. package/build/cjs/index.js +1 -16
  15. package/build/cjs/lib/Database.js +1 -11
  16. package/build/cjs/lib/FakeDOMStringList.js +5 -13
  17. package/build/cjs/lib/FakeEvent.js +3 -10
  18. package/build/cjs/lib/FakeEventTarget.js +15 -32
  19. package/build/cjs/lib/Index.js +14 -46
  20. package/build/cjs/lib/KeyGenerator.js +3 -12
  21. package/build/cjs/lib/ObjectStore.js +24 -63
  22. package/build/cjs/lib/RecordStore.js +4 -42
  23. package/build/cjs/lib/binarySearch.js +5 -24
  24. package/build/cjs/lib/canInjectKey.js +2 -14
  25. package/build/cjs/lib/cmp.js +3 -29
  26. package/build/cjs/lib/enforceRange.js +2 -6
  27. package/build/cjs/lib/errors.js +0 -32
  28. package/build/cjs/lib/extractKey.js +2 -17
  29. package/build/cjs/lib/scheduling.js +4 -7
  30. package/build/cjs/lib/validateKeyPath.js +4 -16
  31. package/build/cjs/lib/valueToKey.js +18 -20
  32. package/build/cjs/lib/valueToKeyRange.js +1 -11
  33. package/build/esm/FDBCursor.js +33 -144
  34. package/build/esm/FDBCursorWithValue.js +0 -5
  35. package/build/esm/FDBDatabase.js +8 -62
  36. package/build/esm/FDBFactory.js +22 -54
  37. package/build/esm/FDBIndex.js +16 -61
  38. package/build/esm/FDBKeyRange.js +4 -22
  39. package/build/esm/FDBObjectStore.js +23 -126
  40. package/build/esm/FDBOpenDBRequest.js +0 -4
  41. package/build/esm/FDBRequest.js +0 -10
  42. package/build/esm/FDBTransaction.js +25 -54
  43. package/build/esm/FDBVersionChangeEvent.js +0 -4
  44. package/build/esm/lib/Database.js +2 -8
  45. package/build/esm/lib/FakeDOMStringList.js +4 -9
  46. package/build/esm/lib/FakeEvent.js +2 -7
  47. package/build/esm/lib/FakeEventTarget.js +14 -29
  48. package/build/esm/lib/Index.js +14 -37
  49. package/build/esm/lib/KeyGenerator.js +2 -8
  50. package/build/esm/lib/ObjectStore.js +19 -51
  51. package/build/esm/lib/RecordStore.js +3 -36
  52. package/build/esm/lib/binarySearch.js +5 -18
  53. package/build/esm/lib/canInjectKey.js +1 -11
  54. package/build/esm/lib/cmp.js +2 -24
  55. package/build/esm/lib/enforceRange.js +1 -3
  56. package/build/esm/lib/errors.js +0 -11
  57. package/build/esm/lib/extractKey.js +3 -13
  58. package/build/esm/lib/scheduling.js +3 -3
  59. package/build/esm/lib/validateKeyPath.js +3 -13
  60. package/build/esm/lib/valueToKey.js +17 -17
  61. package/build/esm/lib/valueToKeyRange.js +2 -5
  62. package/package.json +30 -28
  63. package/build/cjs/lib/structuredClone.js +0 -30
  64. package/build/esm/lib/structuredClone.js +0 -18
@@ -4,33 +4,23 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _FDBKeyRange = _interopRequireDefault(require("../FDBKeyRange.js"));
9
-
10
8
  var _errors = require("./errors.js");
11
-
12
9
  var _valueToKey = _interopRequireDefault(require("./valueToKey.js"));
13
-
14
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
16
11
  // http://w3c.github.io/IndexedDB/#convert-a-value-to-a-key-range
17
12
  const valueToKeyRange = (value, nullDisallowedFlag = false) => {
18
13
  if (value instanceof _FDBKeyRange.default) {
19
14
  return value;
20
15
  }
21
-
22
16
  if (value === null || value === undefined) {
23
17
  if (nullDisallowedFlag) {
24
18
  throw new _errors.DataError();
25
19
  }
26
-
27
20
  return new _FDBKeyRange.default(undefined, undefined, false, false);
28
21
  }
29
-
30
22
  const key = (0, _valueToKey.default)(value);
31
23
  return _FDBKeyRange.default.only(key);
32
24
  };
33
-
34
- var _default = valueToKeyRange;
35
- exports.default = _default;
25
+ var _default = exports.default = valueToKeyRange;
36
26
  module.exports = exports.default;
@@ -3,172 +3,143 @@ import FDBObjectStore from "./FDBObjectStore.js";
3
3
  import cmp from "./lib/cmp.js";
4
4
  import { DataError, InvalidAccessError, InvalidStateError, ReadOnlyError, TransactionInactiveError } from "./lib/errors.js";
5
5
  import extractKey from "./lib/extractKey.js";
6
- import structuredClone from "./lib/structuredClone.js";
7
6
  import valueToKey from "./lib/valueToKey.js";
8
-
9
7
  const getEffectiveObjectStore = cursor => {
10
8
  if (cursor.source instanceof FDBObjectStore) {
11
9
  return cursor.source;
12
10
  }
13
-
14
11
  return cursor.source.objectStore;
15
- }; // This takes a key range, a list of lower bounds, and a list of upper bounds and combines them all into a single key
12
+ };
13
+
14
+ // This takes a key range, a list of lower bounds, and a list of upper bounds and combines them all into a single key
16
15
  // range. It does not handle gt/gte distinctions, because it doesn't really matter much anyway, since for next/prev
17
16
  // cursor iteration it'd also have to look at values to be precise, which would be complicated. This should get us 99%
18
17
  // of the way there.
19
-
20
-
21
18
  const makeKeyRange = (range, lowers, uppers) => {
22
19
  // Start with bounds from range
23
20
  let lower = range !== undefined ? range.lower : undefined;
24
- let upper = range !== undefined ? range.upper : undefined; // Augment with values from lowers and uppers
21
+ let upper = range !== undefined ? range.upper : undefined;
25
22
 
23
+ // Augment with values from lowers and uppers
26
24
  for (const lowerTemp of lowers) {
27
25
  if (lowerTemp === undefined) {
28
26
  continue;
29
27
  }
30
-
31
28
  if (lower === undefined || cmp(lower, lowerTemp) === 1) {
32
29
  lower = lowerTemp;
33
30
  }
34
31
  }
35
-
36
32
  for (const upperTemp of uppers) {
37
33
  if (upperTemp === undefined) {
38
34
  continue;
39
35
  }
40
-
41
36
  if (upper === undefined || cmp(upper, upperTemp) === -1) {
42
37
  upper = upperTemp;
43
38
  }
44
39
  }
45
-
46
40
  if (lower !== undefined && upper !== undefined) {
47
41
  return FDBKeyRange.bound(lower, upper);
48
42
  }
49
-
50
43
  if (lower !== undefined) {
51
44
  return FDBKeyRange.lowerBound(lower);
52
45
  }
53
-
54
46
  if (upper !== undefined) {
55
47
  return FDBKeyRange.upperBound(upper);
56
48
  }
57
- }; // http://www.w3.org/TR/2015/REC-IndexedDB-20150108/#cursor
58
-
49
+ };
59
50
 
51
+ // http://www.w3.org/TR/2015/REC-IndexedDB-20150108/#cursor
60
52
  class FDBCursor {
61
53
  _gotValue = false;
62
54
  _position = undefined; // Key of previously returned record
63
-
64
55
  _objectStorePosition = undefined;
65
56
  _keyOnly = false;
66
57
  _key = undefined;
67
58
  _primaryKey = undefined;
68
-
69
59
  constructor(source, range, direction = "next", request, keyOnly = false) {
70
60
  this._range = range;
71
61
  this._source = source;
72
62
  this._direction = direction;
73
63
  this._request = request;
74
64
  this._keyOnly = keyOnly;
75
- } // Read only properties
76
-
65
+ }
77
66
 
67
+ // Read only properties
78
68
  get source() {
79
69
  return this._source;
80
70
  }
81
-
82
71
  set source(val) {
83
72
  /* For babel */
84
73
  }
85
-
86
74
  get request() {
87
75
  return this._request;
88
76
  }
89
-
90
77
  set request(val) {
91
78
  /* For babel */
92
79
  }
93
-
94
80
  get direction() {
95
81
  return this._direction;
96
82
  }
97
-
98
83
  set direction(val) {
99
84
  /* For babel */
100
85
  }
101
-
102
86
  get key() {
103
87
  return this._key;
104
88
  }
105
-
106
89
  set key(val) {
107
90
  /* For babel */
108
91
  }
109
-
110
92
  get primaryKey() {
111
93
  return this._primaryKey;
112
94
  }
113
-
114
95
  set primaryKey(val) {
115
96
  /* For babel */
116
- } // https://w3c.github.io/IndexedDB/#iterate-a-cursor
117
-
97
+ }
118
98
 
99
+ // https://w3c.github.io/IndexedDB/#iterate-a-cursor
119
100
  _iterate(key, primaryKey) {
120
- const sourceIsObjectStore = this.source instanceof FDBObjectStore; // Can't use sourceIsObjectStore because TypeScript
101
+ const sourceIsObjectStore = this.source instanceof FDBObjectStore;
121
102
 
103
+ // Can't use sourceIsObjectStore because TypeScript
122
104
  const records = this.source instanceof FDBObjectStore ? this.source._rawObjectStore.records : this.source._rawIndex.records;
123
105
  let foundRecord;
124
-
125
106
  if (this.direction === "next") {
126
107
  const range = makeKeyRange(this._range, [key, this._position], []);
127
-
128
108
  for (const record of records.values(range)) {
129
109
  const cmpResultKey = key !== undefined ? cmp(record.key, key) : undefined;
130
110
  const cmpResultPosition = this._position !== undefined ? cmp(record.key, this._position) : undefined;
131
-
132
111
  if (key !== undefined) {
133
112
  if (cmpResultKey === -1) {
134
113
  continue;
135
114
  }
136
115
  }
137
-
138
116
  if (primaryKey !== undefined) {
139
117
  if (cmpResultKey === -1) {
140
118
  continue;
141
119
  }
142
-
143
120
  const cmpResultPrimaryKey = cmp(record.value, primaryKey);
144
-
145
121
  if (cmpResultKey === 0 && cmpResultPrimaryKey === -1) {
146
122
  continue;
147
123
  }
148
124
  }
149
-
150
125
  if (this._position !== undefined && sourceIsObjectStore) {
151
126
  if (cmpResultPosition !== 1) {
152
127
  continue;
153
128
  }
154
129
  }
155
-
156
130
  if (this._position !== undefined && !sourceIsObjectStore) {
157
131
  if (cmpResultPosition === -1) {
158
132
  continue;
159
133
  }
160
-
161
134
  if (cmpResultPosition === 0 && cmp(record.value, this._objectStorePosition) !== 1) {
162
135
  continue;
163
136
  }
164
137
  }
165
-
166
138
  if (this._range !== undefined) {
167
139
  if (!this._range.includes(record.key)) {
168
140
  continue;
169
141
  }
170
142
  }
171
-
172
143
  foundRecord = record;
173
144
  break;
174
145
  }
@@ -177,210 +148,168 @@ class FDBCursor {
177
148
  // But the performance difference should be small, and that wouldn't work anyway for directions where the
178
149
  // value needs to be used (like next and prev).
179
150
  const range = makeKeyRange(this._range, [key, this._position], []);
180
-
181
151
  for (const record of records.values(range)) {
182
152
  if (key !== undefined) {
183
153
  if (cmp(record.key, key) === -1) {
184
154
  continue;
185
155
  }
186
156
  }
187
-
188
157
  if (this._position !== undefined) {
189
158
  if (cmp(record.key, this._position) !== 1) {
190
159
  continue;
191
160
  }
192
161
  }
193
-
194
162
  if (this._range !== undefined) {
195
163
  if (!this._range.includes(record.key)) {
196
164
  continue;
197
165
  }
198
166
  }
199
-
200
167
  foundRecord = record;
201
168
  break;
202
169
  }
203
170
  } else if (this.direction === "prev") {
204
171
  const range = makeKeyRange(this._range, [], [key, this._position]);
205
-
206
172
  for (const record of records.values(range, "prev")) {
207
173
  const cmpResultKey = key !== undefined ? cmp(record.key, key) : undefined;
208
174
  const cmpResultPosition = this._position !== undefined ? cmp(record.key, this._position) : undefined;
209
-
210
175
  if (key !== undefined) {
211
176
  if (cmpResultKey === 1) {
212
177
  continue;
213
178
  }
214
179
  }
215
-
216
180
  if (primaryKey !== undefined) {
217
181
  if (cmpResultKey === 1) {
218
182
  continue;
219
183
  }
220
-
221
184
  const cmpResultPrimaryKey = cmp(record.value, primaryKey);
222
-
223
185
  if (cmpResultKey === 0 && cmpResultPrimaryKey === 1) {
224
186
  continue;
225
187
  }
226
188
  }
227
-
228
189
  if (this._position !== undefined && sourceIsObjectStore) {
229
190
  if (cmpResultPosition !== -1) {
230
191
  continue;
231
192
  }
232
193
  }
233
-
234
194
  if (this._position !== undefined && !sourceIsObjectStore) {
235
195
  if (cmpResultPosition === 1) {
236
196
  continue;
237
197
  }
238
-
239
198
  if (cmpResultPosition === 0 && cmp(record.value, this._objectStorePosition) !== -1) {
240
199
  continue;
241
200
  }
242
201
  }
243
-
244
202
  if (this._range !== undefined) {
245
203
  if (!this._range.includes(record.key)) {
246
204
  continue;
247
205
  }
248
206
  }
249
-
250
207
  foundRecord = record;
251
208
  break;
252
209
  }
253
210
  } else if (this.direction === "prevunique") {
254
211
  let tempRecord;
255
212
  const range = makeKeyRange(this._range, [], [key, this._position]);
256
-
257
213
  for (const record of records.values(range, "prev")) {
258
214
  if (key !== undefined) {
259
215
  if (cmp(record.key, key) === 1) {
260
216
  continue;
261
217
  }
262
218
  }
263
-
264
219
  if (this._position !== undefined) {
265
220
  if (cmp(record.key, this._position) !== -1) {
266
221
  continue;
267
222
  }
268
223
  }
269
-
270
224
  if (this._range !== undefined) {
271
225
  if (!this._range.includes(record.key)) {
272
226
  continue;
273
227
  }
274
228
  }
275
-
276
229
  tempRecord = record;
277
230
  break;
278
231
  }
279
-
280
232
  if (tempRecord) {
281
233
  foundRecord = records.get(tempRecord.key);
282
234
  }
283
235
  }
284
-
285
236
  let result;
286
-
287
237
  if (!foundRecord) {
288
238
  this._key = undefined;
289
-
290
239
  if (!sourceIsObjectStore) {
291
240
  this._objectStorePosition = undefined;
292
- } // "this instanceof FDBCursorWithValue" would be better and not require (this as any), but causes runtime
293
- // error due to circular dependency.
294
-
241
+ }
295
242
 
243
+ // "this instanceof FDBCursorWithValue" would be better and not require (this as any), but causes runtime
244
+ // error due to circular dependency.
296
245
  if (!this._keyOnly && this.toString() === "[object IDBCursorWithValue]") {
297
246
  this.value = undefined;
298
247
  }
299
-
300
248
  result = null;
301
249
  } else {
302
250
  this._position = foundRecord.key;
303
-
304
251
  if (!sourceIsObjectStore) {
305
252
  this._objectStorePosition = foundRecord.value;
306
253
  }
307
-
308
254
  this._key = foundRecord.key;
309
-
310
255
  if (sourceIsObjectStore) {
311
256
  this._primaryKey = structuredClone(foundRecord.key);
312
-
313
257
  if (!this._keyOnly && this.toString() === "[object IDBCursorWithValue]") {
314
258
  this.value = structuredClone(foundRecord.value);
315
259
  }
316
260
  } else {
317
261
  this._primaryKey = structuredClone(foundRecord.value);
318
-
319
262
  if (!this._keyOnly && this.toString() === "[object IDBCursorWithValue]") {
320
263
  if (this.source instanceof FDBObjectStore) {
321
264
  // Can't use sourceIsObjectStore because TypeScript
322
265
  throw new Error("This should never happen");
323
266
  }
324
-
325
267
  const value = this.source.objectStore._rawObjectStore.getValue(foundRecord.value);
326
-
327
268
  this.value = structuredClone(value);
328
269
  }
329
270
  }
330
-
331
271
  this._gotValue = true;
272
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
332
273
  result = this;
333
274
  }
334
-
335
275
  return result;
336
- } // http://www.w3.org/TR/2015/REC-IndexedDB-20150108/#widl-IDBCursor-update-IDBRequest-any-value
337
-
276
+ }
338
277
 
278
+ // http://www.w3.org/TR/2015/REC-IndexedDB-20150108/#widl-IDBCursor-update-IDBRequest-any-value
339
279
  update(value) {
340
280
  if (value === undefined) {
341
281
  throw new TypeError();
342
282
  }
343
-
344
283
  const effectiveObjectStore = getEffectiveObjectStore(this);
345
- const effectiveKey = this.source.hasOwnProperty("_rawIndex") ? this.primaryKey : this._position;
284
+ const effectiveKey = Object.hasOwn(this.source, "_rawIndex") ? this.primaryKey : this._position;
346
285
  const transaction = effectiveObjectStore.transaction;
347
-
348
286
  if (transaction._state !== "active") {
349
287
  throw new TransactionInactiveError();
350
288
  }
351
-
352
289
  if (transaction.mode === "readonly") {
353
290
  throw new ReadOnlyError();
354
291
  }
355
-
356
292
  if (effectiveObjectStore._rawObjectStore.deleted) {
357
293
  throw new InvalidStateError();
358
294
  }
359
-
360
295
  if (!(this.source instanceof FDBObjectStore) && this.source._rawIndex.deleted) {
361
296
  throw new InvalidStateError();
362
297
  }
363
-
364
- if (!this._gotValue || !this.hasOwnProperty("value")) {
298
+ if (!this._gotValue || !Object.hasOwn(this, "value")) {
365
299
  throw new InvalidStateError();
366
300
  }
367
-
368
301
  const clone = structuredClone(value);
369
-
370
302
  if (effectiveObjectStore.keyPath !== null) {
371
303
  let tempKey;
372
-
373
304
  try {
374
305
  tempKey = extractKey(effectiveObjectStore.keyPath, clone);
375
306
  } catch (err) {
376
307
  /* Handled immediately below */
377
308
  }
378
-
379
309
  if (cmp(tempKey, effectiveKey) !== 0) {
380
310
  throw new DataError();
381
311
  }
382
312
  }
383
-
384
313
  const record = {
385
314
  key: effectiveKey,
386
315
  value: clone
@@ -389,194 +318,154 @@ class FDBCursor {
389
318
  operation: effectiveObjectStore._rawObjectStore.storeRecord.bind(effectiveObjectStore._rawObjectStore, record, false, transaction._rollbackLog),
390
319
  source: this
391
320
  });
392
- } // http://www.w3.org/TR/2015/REC-IndexedDB-20150108/#widl-IDBCursor-advance-void-unsigned-long-count
393
-
321
+ }
394
322
 
323
+ // http://www.w3.org/TR/2015/REC-IndexedDB-20150108/#widl-IDBCursor-advance-void-unsigned-long-count
395
324
  advance(count) {
396
325
  if (!Number.isInteger(count) || count <= 0) {
397
326
  throw new TypeError();
398
327
  }
399
-
400
328
  const effectiveObjectStore = getEffectiveObjectStore(this);
401
329
  const transaction = effectiveObjectStore.transaction;
402
-
403
330
  if (transaction._state !== "active") {
404
331
  throw new TransactionInactiveError();
405
332
  }
406
-
407
333
  if (effectiveObjectStore._rawObjectStore.deleted) {
408
334
  throw new InvalidStateError();
409
335
  }
410
-
411
336
  if (!(this.source instanceof FDBObjectStore) && this.source._rawIndex.deleted) {
412
337
  throw new InvalidStateError();
413
338
  }
414
-
415
339
  if (!this._gotValue) {
416
340
  throw new InvalidStateError();
417
341
  }
418
-
419
342
  if (this._request) {
420
343
  this._request.readyState = "pending";
421
344
  }
422
-
423
345
  transaction._execRequestAsync({
424
346
  operation: () => {
425
347
  let result;
426
-
427
348
  for (let i = 0; i < count; i++) {
428
- result = this._iterate(); // Not sure why this is needed
349
+ result = this._iterate();
429
350
 
351
+ // Not sure why this is needed
430
352
  if (!result) {
431
353
  break;
432
354
  }
433
355
  }
434
-
435
356
  return result;
436
357
  },
437
358
  request: this._request,
438
359
  source: this.source
439
360
  });
440
-
441
361
  this._gotValue = false;
442
- } // http://www.w3.org/TR/2015/REC-IndexedDB-20150108/#widl-IDBCursor-continue-void-any-key
443
-
362
+ }
444
363
 
364
+ // http://www.w3.org/TR/2015/REC-IndexedDB-20150108/#widl-IDBCursor-continue-void-any-key
445
365
  continue(key) {
446
366
  const effectiveObjectStore = getEffectiveObjectStore(this);
447
367
  const transaction = effectiveObjectStore.transaction;
448
-
449
368
  if (transaction._state !== "active") {
450
369
  throw new TransactionInactiveError();
451
370
  }
452
-
453
371
  if (effectiveObjectStore._rawObjectStore.deleted) {
454
372
  throw new InvalidStateError();
455
373
  }
456
-
457
374
  if (!(this.source instanceof FDBObjectStore) && this.source._rawIndex.deleted) {
458
375
  throw new InvalidStateError();
459
376
  }
460
-
461
377
  if (!this._gotValue) {
462
378
  throw new InvalidStateError();
463
379
  }
464
-
465
380
  if (key !== undefined) {
466
381
  key = valueToKey(key);
467
382
  const cmpResult = cmp(key, this._position);
468
-
469
383
  if (cmpResult <= 0 && (this.direction === "next" || this.direction === "nextunique") || cmpResult >= 0 && (this.direction === "prev" || this.direction === "prevunique")) {
470
384
  throw new DataError();
471
385
  }
472
386
  }
473
-
474
387
  if (this._request) {
475
388
  this._request.readyState = "pending";
476
389
  }
477
-
478
390
  transaction._execRequestAsync({
479
391
  operation: this._iterate.bind(this, key),
480
392
  request: this._request,
481
393
  source: this.source
482
394
  });
483
-
484
395
  this._gotValue = false;
485
- } // hthttps://w3c.github.io/IndexedDB/#dom-idbcursor-continueprimarykey
486
-
396
+ }
487
397
 
398
+ // hthttps://w3c.github.io/IndexedDB/#dom-idbcursor-continueprimarykey
488
399
  continuePrimaryKey(key, primaryKey) {
489
400
  const effectiveObjectStore = getEffectiveObjectStore(this);
490
401
  const transaction = effectiveObjectStore.transaction;
491
-
492
402
  if (transaction._state !== "active") {
493
403
  throw new TransactionInactiveError();
494
404
  }
495
-
496
405
  if (effectiveObjectStore._rawObjectStore.deleted) {
497
406
  throw new InvalidStateError();
498
407
  }
499
-
500
408
  if (!(this.source instanceof FDBObjectStore) && this.source._rawIndex.deleted) {
501
409
  throw new InvalidStateError();
502
410
  }
503
-
504
411
  if (this.source instanceof FDBObjectStore || this.direction !== "next" && this.direction !== "prev") {
505
412
  throw new InvalidAccessError();
506
413
  }
507
-
508
414
  if (!this._gotValue) {
509
415
  throw new InvalidStateError();
510
- } // Not sure about this
511
-
416
+ }
512
417
 
418
+ // Not sure about this
513
419
  if (key === undefined || primaryKey === undefined) {
514
420
  throw new DataError();
515
421
  }
516
-
517
422
  key = valueToKey(key);
518
423
  const cmpResult = cmp(key, this._position);
519
-
520
424
  if (cmpResult === -1 && this.direction === "next" || cmpResult === 1 && this.direction === "prev") {
521
425
  throw new DataError();
522
426
  }
523
-
524
427
  const cmpResult2 = cmp(primaryKey, this._objectStorePosition);
525
-
526
428
  if (cmpResult === 0) {
527
429
  if (cmpResult2 <= 0 && this.direction === "next" || cmpResult2 >= 0 && this.direction === "prev") {
528
430
  throw new DataError();
529
431
  }
530
432
  }
531
-
532
433
  if (this._request) {
533
434
  this._request.readyState = "pending";
534
435
  }
535
-
536
436
  transaction._execRequestAsync({
537
437
  operation: this._iterate.bind(this, key, primaryKey),
538
438
  request: this._request,
539
439
  source: this.source
540
440
  });
541
-
542
441
  this._gotValue = false;
543
442
  }
544
-
545
443
  delete() {
546
444
  const effectiveObjectStore = getEffectiveObjectStore(this);
547
- const effectiveKey = this.source.hasOwnProperty("_rawIndex") ? this.primaryKey : this._position;
445
+ const effectiveKey = Object.hasOwn(this.source, "_rawIndex") ? this.primaryKey : this._position;
548
446
  const transaction = effectiveObjectStore.transaction;
549
-
550
447
  if (transaction._state !== "active") {
551
448
  throw new TransactionInactiveError();
552
449
  }
553
-
554
450
  if (transaction.mode === "readonly") {
555
451
  throw new ReadOnlyError();
556
452
  }
557
-
558
453
  if (effectiveObjectStore._rawObjectStore.deleted) {
559
454
  throw new InvalidStateError();
560
455
  }
561
-
562
456
  if (!(this.source instanceof FDBObjectStore) && this.source._rawIndex.deleted) {
563
457
  throw new InvalidStateError();
564
458
  }
565
-
566
- if (!this._gotValue || !this.hasOwnProperty("value")) {
459
+ if (!this._gotValue || !Object.hasOwn(this, "value")) {
567
460
  throw new InvalidStateError();
568
461
  }
569
-
570
462
  return transaction._execRequestAsync({
571
463
  operation: effectiveObjectStore._rawObjectStore.deleteRecord.bind(effectiveObjectStore._rawObjectStore, effectiveKey, transaction._rollbackLog),
572
464
  source: this
573
465
  });
574
466
  }
575
-
576
467
  toString() {
577
468
  return "[object IDBCursor]";
578
469
  }
579
-
580
470
  }
581
-
582
471
  export default FDBCursor;
@@ -1,16 +1,11 @@
1
1
  import FDBCursor from "./FDBCursor.js";
2
-
3
2
  class FDBCursorWithValue extends FDBCursor {
4
3
  value = undefined;
5
-
6
4
  constructor(source, range, direction, request) {
7
5
  super(source, range, direction, request);
8
6
  }
9
-
10
7
  toString() {
11
8
  return "[object IDBCursorWithValue]";
12
9
  }
13
-
14
10
  }
15
-
16
11
  export default FDBCursorWithValue;