fake-indexeddb 4.0.0-beta.1 → 4.0.0-beta.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/README.md CHANGED
@@ -115,7 +115,7 @@ const db = new Dexie("MyDatabase", { indexedDB: indexedDB, IDBKeyRange: IDBKeyRa
115
115
 
116
116
  ### Jest
117
117
 
118
- Out of the box, Jest v27 only supports CommonJS, not ES modules, so [you'll have to do a little extra work to opt in to ES modules](https://jestjs.io/docs/ecmascript-modules). If you can't do that, you should switch to fake-indexeddb v3, see the above "ECMAScript modules" section for more info.
118
+ Out of the box, Jest v27 only supports CommonJS, not ES modules, so you'll have to do a little extra work to opt in to ES modules, either [for all your test files](https://jestjs.io/docs/ecmascript-modules) or by configuring Jest to [transpile fake-indexeddb](https://stackoverflow.com/a/43197503/786644). If you can't do that, you should use fake-indexeddb v3, see the above "ECMAScript modules" section for more info.
119
119
 
120
120
  To use fake-indexeddb in a single Jest test suite, require `fake-indexeddb/auto` at the beginning of the test
121
121
  file, as described above.
@@ -133,7 +133,7 @@ To use it on all Jest tests without having to require it in each file, add the a
133
133
 
134
134
  ### Wiping/resetting the indexedDB for a fresh state
135
135
 
136
- If you are keeping your tests completely isolated you might want to "reset" the state of the mocked indexedDB. You can do this by creating a new `fakeIndexedDB` instance, which lets you have a totally fresh start.
136
+ If you are keeping your tests completely isolated you might want to "reset" the state of the mocked indexedDB. You can do this by creating a new instance of `IDBFactory`, which lets you have a totally fresh start.
137
137
 
138
138
  ```
139
139
  import "fake-indexeddb/auto";
@@ -1,14 +1,3 @@
1
- var __values = (this && this.__values) || function(o) {
2
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
3
- if (m) return m.call(o);
4
- if (o && typeof o.length === "number") return {
5
- next: function () {
6
- if (o && i >= o.length) o = void 0;
7
- return { value: o && o[i++], done: !o };
8
- }
9
- };
10
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
11
- };
12
1
  import FDBKeyRange from "./FDBKeyRange.js";
13
2
  import FDBObjectStore from "./FDBObjectStore.js";
14
3
  import cmp from "./lib/cmp.js";
@@ -16,7 +5,7 @@ import { DataError, InvalidAccessError, InvalidStateError, ReadOnlyError, Transa
16
5
  import extractKey from "./lib/extractKey.js";
17
6
  import structuredClone from "./lib/structuredClone.js";
18
7
  import valueToKey from "./lib/valueToKey.js";
19
- var getEffectiveObjectStore = function (cursor) {
8
+ const getEffectiveObjectStore = (cursor) => {
20
9
  if (cursor.source instanceof FDBObjectStore) {
21
10
  return cursor.source;
22
11
  }
@@ -26,47 +15,26 @@ var getEffectiveObjectStore = function (cursor) {
26
15
  // range. It does not handle gt/gte distinctions, because it doesn't really matter much anyway, since for next/prev
27
16
  // cursor iteration it'd also have to look at values to be precise, which would be complicated. This should get us 99%
28
17
  // of the way there.
29
- var makeKeyRange = function (range, lowers, uppers) {
30
- var e_1, _a, e_2, _b;
18
+ const makeKeyRange = (range, lowers, uppers) => {
31
19
  // Start with bounds from range
32
- var lower = range !== undefined ? range.lower : undefined;
33
- var upper = range !== undefined ? range.upper : undefined;
34
- try {
35
- // Augment with values from lowers and uppers
36
- for (var lowers_1 = __values(lowers), lowers_1_1 = lowers_1.next(); !lowers_1_1.done; lowers_1_1 = lowers_1.next()) {
37
- var lowerTemp = lowers_1_1.value;
38
- if (lowerTemp === undefined) {
39
- continue;
40
- }
41
- if (lower === undefined || cmp(lower, lowerTemp) === 1) {
42
- lower = lowerTemp;
43
- }
20
+ let lower = range !== undefined ? range.lower : undefined;
21
+ let upper = range !== undefined ? range.upper : undefined;
22
+ // Augment with values from lowers and uppers
23
+ for (const lowerTemp of lowers) {
24
+ if (lowerTemp === undefined) {
25
+ continue;
44
26
  }
45
- }
46
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
47
- finally {
48
- try {
49
- if (lowers_1_1 && !lowers_1_1.done && (_a = lowers_1.return)) _a.call(lowers_1);
27
+ if (lower === undefined || cmp(lower, lowerTemp) === 1) {
28
+ lower = lowerTemp;
50
29
  }
51
- finally { if (e_1) throw e_1.error; }
52
30
  }
53
- try {
54
- for (var uppers_1 = __values(uppers), uppers_1_1 = uppers_1.next(); !uppers_1_1.done; uppers_1_1 = uppers_1.next()) {
55
- var upperTemp = uppers_1_1.value;
56
- if (upperTemp === undefined) {
57
- continue;
58
- }
59
- if (upper === undefined || cmp(upper, upperTemp) === -1) {
60
- upper = upperTemp;
61
- }
31
+ for (const upperTemp of uppers) {
32
+ if (upperTemp === undefined) {
33
+ continue;
62
34
  }
63
- }
64
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
65
- finally {
66
- try {
67
- if (uppers_1_1 && !uppers_1_1.done && (_b = uppers_1.return)) _b.call(uppers_1);
35
+ if (upper === undefined || cmp(upper, upperTemp) === -1) {
36
+ upper = upperTemp;
68
37
  }
69
- finally { if (e_2) throw e_2.error; }
70
38
  }
71
39
  if (lower !== undefined && upper !== undefined) {
72
40
  return FDBKeyRange.bound(lower, upper);
@@ -79,10 +47,8 @@ var makeKeyRange = function (range, lowers, uppers) {
79
47
  }
80
48
  };
81
49
  // http://www.w3.org/TR/2015/REC-IndexedDB-20150108/#cursor
82
- var FDBCursor = /** @class */ (function () {
83
- function FDBCursor(source, range, direction, request, keyOnly) {
84
- if (direction === void 0) { direction = "next"; }
85
- if (keyOnly === void 0) { keyOnly = false; }
50
+ class FDBCursor {
51
+ constructor(source, range, direction = "next", request, keyOnly = false) {
86
52
  this._gotValue = false;
87
53
  this._position = undefined; // Key of previously returned record
88
54
  this._objectStorePosition = undefined;
@@ -95,236 +61,179 @@ var FDBCursor = /** @class */ (function () {
95
61
  this._request = request;
96
62
  this._keyOnly = keyOnly;
97
63
  }
98
- Object.defineProperty(FDBCursor.prototype, "source", {
99
- // Read only properties
100
- get: function () {
101
- return this._source;
102
- },
103
- set: function (val) {
104
- /* For babel */
105
- },
106
- enumerable: false,
107
- configurable: true
108
- });
109
- Object.defineProperty(FDBCursor.prototype, "direction", {
110
- get: function () {
111
- return this._direction;
112
- },
113
- set: function (val) {
114
- /* For babel */
115
- },
116
- enumerable: false,
117
- configurable: true
118
- });
119
- Object.defineProperty(FDBCursor.prototype, "key", {
120
- get: function () {
121
- return this._key;
122
- },
123
- set: function (val) {
124
- /* For babel */
125
- },
126
- enumerable: false,
127
- configurable: true
128
- });
129
- Object.defineProperty(FDBCursor.prototype, "primaryKey", {
130
- get: function () {
131
- return this._primaryKey;
132
- },
133
- set: function (val) {
134
- /* For babel */
135
- },
136
- enumerable: false,
137
- configurable: true
138
- });
64
+ // Read only properties
65
+ get source() {
66
+ return this._source;
67
+ }
68
+ set source(val) {
69
+ /* For babel */
70
+ }
71
+ get direction() {
72
+ return this._direction;
73
+ }
74
+ set direction(val) {
75
+ /* For babel */
76
+ }
77
+ get key() {
78
+ return this._key;
79
+ }
80
+ set key(val) {
81
+ /* For babel */
82
+ }
83
+ get primaryKey() {
84
+ return this._primaryKey;
85
+ }
86
+ set primaryKey(val) {
87
+ /* For babel */
88
+ }
139
89
  // https://w3c.github.io/IndexedDB/#iterate-a-cursor
140
- FDBCursor.prototype._iterate = function (key, primaryKey) {
141
- var e_3, _a, e_4, _b, e_5, _c, e_6, _d;
142
- var sourceIsObjectStore = this.source instanceof FDBObjectStore;
90
+ _iterate(key, primaryKey) {
91
+ const sourceIsObjectStore = this.source instanceof FDBObjectStore;
143
92
  // Can't use sourceIsObjectStore because TypeScript
144
- var records = this.source instanceof FDBObjectStore
93
+ const records = this.source instanceof FDBObjectStore
145
94
  ? this.source._rawObjectStore.records
146
95
  : this.source._rawIndex.records;
147
- var foundRecord;
96
+ let foundRecord;
148
97
  if (this.direction === "next") {
149
- var range = makeKeyRange(this._range, [key, this._position], []);
150
- try {
151
- for (var _e = __values(records.values(range)), _f = _e.next(); !_f.done; _f = _e.next()) {
152
- var record = _f.value;
153
- var cmpResultKey = key !== undefined ? cmp(record.key, key) : undefined;
154
- var cmpResultPosition = this._position !== undefined
155
- ? cmp(record.key, this._position)
156
- : undefined;
157
- if (key !== undefined) {
158
- if (cmpResultKey === -1) {
159
- continue;
160
- }
98
+ const range = makeKeyRange(this._range, [key, this._position], []);
99
+ for (const record of records.values(range)) {
100
+ const cmpResultKey = key !== undefined ? cmp(record.key, key) : undefined;
101
+ const cmpResultPosition = this._position !== undefined
102
+ ? cmp(record.key, this._position)
103
+ : undefined;
104
+ if (key !== undefined) {
105
+ if (cmpResultKey === -1) {
106
+ continue;
161
107
  }
162
- if (primaryKey !== undefined) {
163
- if (cmpResultKey === -1) {
164
- continue;
165
- }
166
- var cmpResultPrimaryKey = cmp(record.value, primaryKey);
167
- if (cmpResultKey === 0 && cmpResultPrimaryKey === -1) {
168
- continue;
169
- }
108
+ }
109
+ if (primaryKey !== undefined) {
110
+ if (cmpResultKey === -1) {
111
+ continue;
170
112
  }
171
- if (this._position !== undefined && sourceIsObjectStore) {
172
- if (cmpResultPosition !== 1) {
173
- continue;
174
- }
113
+ const cmpResultPrimaryKey = cmp(record.value, primaryKey);
114
+ if (cmpResultKey === 0 && cmpResultPrimaryKey === -1) {
115
+ continue;
175
116
  }
176
- if (this._position !== undefined && !sourceIsObjectStore) {
177
- if (cmpResultPosition === -1) {
178
- continue;
179
- }
180
- if (cmpResultPosition === 0 &&
181
- cmp(record.value, this._objectStorePosition) !== 1) {
182
- continue;
183
- }
117
+ }
118
+ if (this._position !== undefined && sourceIsObjectStore) {
119
+ if (cmpResultPosition !== 1) {
120
+ continue;
184
121
  }
185
- if (this._range !== undefined) {
186
- if (!this._range.includes(record.key)) {
187
- continue;
188
- }
122
+ }
123
+ if (this._position !== undefined && !sourceIsObjectStore) {
124
+ if (cmpResultPosition === -1) {
125
+ continue;
126
+ }
127
+ if (cmpResultPosition === 0 &&
128
+ cmp(record.value, this._objectStorePosition) !== 1) {
129
+ continue;
189
130
  }
190
- foundRecord = record;
191
- break;
192
131
  }
193
- }
194
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
195
- finally {
196
- try {
197
- if (_f && !_f.done && (_a = _e.return)) _a.call(_e);
132
+ if (this._range !== undefined) {
133
+ if (!this._range.includes(record.key)) {
134
+ continue;
135
+ }
198
136
  }
199
- finally { if (e_3) throw e_3.error; }
137
+ foundRecord = record;
138
+ break;
200
139
  }
201
140
  }
202
141
  else if (this.direction === "nextunique") {
203
142
  // This could be done without iterating, if the range was defined slightly better (to handle gt/gte cases).
204
143
  // But the performance difference should be small, and that wouldn't work anyway for directions where the
205
144
  // value needs to be used (like next and prev).
206
- var range = makeKeyRange(this._range, [key, this._position], []);
207
- try {
208
- for (var _g = __values(records.values(range)), _h = _g.next(); !_h.done; _h = _g.next()) {
209
- var record = _h.value;
210
- if (key !== undefined) {
211
- if (cmp(record.key, key) === -1) {
212
- continue;
213
- }
145
+ const range = makeKeyRange(this._range, [key, this._position], []);
146
+ for (const record of records.values(range)) {
147
+ if (key !== undefined) {
148
+ if (cmp(record.key, key) === -1) {
149
+ continue;
214
150
  }
215
- if (this._position !== undefined) {
216
- if (cmp(record.key, this._position) !== 1) {
217
- continue;
218
- }
219
- }
220
- if (this._range !== undefined) {
221
- if (!this._range.includes(record.key)) {
222
- continue;
223
- }
151
+ }
152
+ if (this._position !== undefined) {
153
+ if (cmp(record.key, this._position) !== 1) {
154
+ continue;
224
155
  }
225
- foundRecord = record;
226
- break;
227
156
  }
228
- }
229
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
230
- finally {
231
- try {
232
- if (_h && !_h.done && (_b = _g.return)) _b.call(_g);
157
+ if (this._range !== undefined) {
158
+ if (!this._range.includes(record.key)) {
159
+ continue;
160
+ }
233
161
  }
234
- finally { if (e_4) throw e_4.error; }
162
+ foundRecord = record;
163
+ break;
235
164
  }
236
165
  }
237
166
  else if (this.direction === "prev") {
238
- var range = makeKeyRange(this._range, [], [key, this._position]);
239
- try {
240
- for (var _j = __values(records.values(range, "prev")), _k = _j.next(); !_k.done; _k = _j.next()) {
241
- var record = _k.value;
242
- var cmpResultKey = key !== undefined ? cmp(record.key, key) : undefined;
243
- var cmpResultPosition = this._position !== undefined
244
- ? cmp(record.key, this._position)
245
- : undefined;
246
- if (key !== undefined) {
247
- if (cmpResultKey === 1) {
248
- continue;
249
- }
167
+ const range = makeKeyRange(this._range, [], [key, this._position]);
168
+ for (const record of records.values(range, "prev")) {
169
+ const cmpResultKey = key !== undefined ? cmp(record.key, key) : undefined;
170
+ const cmpResultPosition = this._position !== undefined
171
+ ? cmp(record.key, this._position)
172
+ : undefined;
173
+ if (key !== undefined) {
174
+ if (cmpResultKey === 1) {
175
+ continue;
176
+ }
177
+ }
178
+ if (primaryKey !== undefined) {
179
+ if (cmpResultKey === 1) {
180
+ continue;
250
181
  }
251
- if (primaryKey !== undefined) {
252
- if (cmpResultKey === 1) {
253
- continue;
254
- }
255
- var cmpResultPrimaryKey = cmp(record.value, primaryKey);
256
- if (cmpResultKey === 0 && cmpResultPrimaryKey === 1) {
257
- continue;
258
- }
182
+ const cmpResultPrimaryKey = cmp(record.value, primaryKey);
183
+ if (cmpResultKey === 0 && cmpResultPrimaryKey === 1) {
184
+ continue;
259
185
  }
260
- if (this._position !== undefined && sourceIsObjectStore) {
261
- if (cmpResultPosition !== -1) {
262
- continue;
263
- }
186
+ }
187
+ if (this._position !== undefined && sourceIsObjectStore) {
188
+ if (cmpResultPosition !== -1) {
189
+ continue;
264
190
  }
265
- if (this._position !== undefined && !sourceIsObjectStore) {
266
- if (cmpResultPosition === 1) {
267
- continue;
268
- }
269
- if (cmpResultPosition === 0 &&
270
- cmp(record.value, this._objectStorePosition) !== -1) {
271
- continue;
272
- }
191
+ }
192
+ if (this._position !== undefined && !sourceIsObjectStore) {
193
+ if (cmpResultPosition === 1) {
194
+ continue;
273
195
  }
274
- if (this._range !== undefined) {
275
- if (!this._range.includes(record.key)) {
276
- continue;
277
- }
196
+ if (cmpResultPosition === 0 &&
197
+ cmp(record.value, this._objectStorePosition) !== -1) {
198
+ continue;
278
199
  }
279
- foundRecord = record;
280
- break;
281
200
  }
282
- }
283
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
284
- finally {
285
- try {
286
- if (_k && !_k.done && (_c = _j.return)) _c.call(_j);
201
+ if (this._range !== undefined) {
202
+ if (!this._range.includes(record.key)) {
203
+ continue;
204
+ }
287
205
  }
288
- finally { if (e_5) throw e_5.error; }
206
+ foundRecord = record;
207
+ break;
289
208
  }
290
209
  }
291
210
  else if (this.direction === "prevunique") {
292
- var tempRecord = void 0;
293
- var range = makeKeyRange(this._range, [], [key, this._position]);
294
- try {
295
- for (var _l = __values(records.values(range, "prev")), _m = _l.next(); !_m.done; _m = _l.next()) {
296
- var record = _m.value;
297
- if (key !== undefined) {
298
- if (cmp(record.key, key) === 1) {
299
- continue;
300
- }
211
+ let tempRecord;
212
+ const range = makeKeyRange(this._range, [], [key, this._position]);
213
+ for (const record of records.values(range, "prev")) {
214
+ if (key !== undefined) {
215
+ if (cmp(record.key, key) === 1) {
216
+ continue;
301
217
  }
302
- if (this._position !== undefined) {
303
- if (cmp(record.key, this._position) !== -1) {
304
- continue;
305
- }
306
- }
307
- if (this._range !== undefined) {
308
- if (!this._range.includes(record.key)) {
309
- continue;
310
- }
218
+ }
219
+ if (this._position !== undefined) {
220
+ if (cmp(record.key, this._position) !== -1) {
221
+ continue;
311
222
  }
312
- tempRecord = record;
313
- break;
314
223
  }
315
- }
316
- catch (e_6_1) { e_6 = { error: e_6_1 }; }
317
- finally {
318
- try {
319
- if (_m && !_m.done && (_d = _l.return)) _d.call(_l);
224
+ if (this._range !== undefined) {
225
+ if (!this._range.includes(record.key)) {
226
+ continue;
227
+ }
320
228
  }
321
- finally { if (e_6) throw e_6.error; }
229
+ tempRecord = record;
230
+ break;
322
231
  }
323
232
  if (tempRecord) {
324
233
  foundRecord = records.get(tempRecord.key);
325
234
  }
326
235
  }
327
- var result;
236
+ let result;
328
237
  if (!foundRecord) {
329
238
  this._key = undefined;
330
239
  if (!sourceIsObjectStore) {
@@ -359,7 +268,7 @@ var FDBCursor = /** @class */ (function () {
359
268
  // Can't use sourceIsObjectStore because TypeScript
360
269
  throw new Error("This should never happen");
361
270
  }
362
- var value = this.source.objectStore._rawObjectStore.getValue(foundRecord.value);
271
+ const value = this.source.objectStore._rawObjectStore.getValue(foundRecord.value);
363
272
  this.value = structuredClone(value);
364
273
  }
365
274
  }
@@ -367,17 +276,17 @@ var FDBCursor = /** @class */ (function () {
367
276
  result = this;
368
277
  }
369
278
  return result;
370
- };
279
+ }
371
280
  // http://www.w3.org/TR/2015/REC-IndexedDB-20150108/#widl-IDBCursor-update-IDBRequest-any-value
372
- FDBCursor.prototype.update = function (value) {
281
+ update(value) {
373
282
  if (value === undefined) {
374
283
  throw new TypeError();
375
284
  }
376
- var effectiveObjectStore = getEffectiveObjectStore(this);
377
- var effectiveKey = this.source.hasOwnProperty("_rawIndex")
285
+ const effectiveObjectStore = getEffectiveObjectStore(this);
286
+ const effectiveKey = this.source.hasOwnProperty("_rawIndex")
378
287
  ? this.primaryKey
379
288
  : this._position;
380
- var transaction = effectiveObjectStore.transaction;
289
+ const transaction = effectiveObjectStore.transaction;
381
290
  if (transaction._state !== "active") {
382
291
  throw new TransactionInactiveError();
383
292
  }
@@ -394,9 +303,9 @@ var FDBCursor = /** @class */ (function () {
394
303
  if (!this._gotValue || !this.hasOwnProperty("value")) {
395
304
  throw new InvalidStateError();
396
305
  }
397
- var clone = structuredClone(value);
306
+ const clone = structuredClone(value);
398
307
  if (effectiveObjectStore.keyPath !== null) {
399
- var tempKey = void 0;
308
+ let tempKey;
400
309
  try {
401
310
  tempKey = extractKey(effectiveObjectStore.keyPath, clone);
402
311
  }
@@ -407,7 +316,7 @@ var FDBCursor = /** @class */ (function () {
407
316
  throw new DataError();
408
317
  }
409
318
  }
410
- var record = {
319
+ const record = {
411
320
  key: effectiveKey,
412
321
  value: clone,
413
322
  };
@@ -415,15 +324,14 @@ var FDBCursor = /** @class */ (function () {
415
324
  operation: effectiveObjectStore._rawObjectStore.storeRecord.bind(effectiveObjectStore._rawObjectStore, record, false, transaction._rollbackLog),
416
325
  source: this,
417
326
  });
418
- };
327
+ }
419
328
  // http://www.w3.org/TR/2015/REC-IndexedDB-20150108/#widl-IDBCursor-advance-void-unsigned-long-count
420
- FDBCursor.prototype.advance = function (count) {
421
- var _this = this;
329
+ advance(count) {
422
330
  if (!Number.isInteger(count) || count <= 0) {
423
331
  throw new TypeError();
424
332
  }
425
- var effectiveObjectStore = getEffectiveObjectStore(this);
426
- var transaction = effectiveObjectStore.transaction;
333
+ const effectiveObjectStore = getEffectiveObjectStore(this);
334
+ const transaction = effectiveObjectStore.transaction;
427
335
  if (transaction._state !== "active") {
428
336
  throw new TransactionInactiveError();
429
337
  }
@@ -441,10 +349,10 @@ var FDBCursor = /** @class */ (function () {
441
349
  this._request.readyState = "pending";
442
350
  }
443
351
  transaction._execRequestAsync({
444
- operation: function () {
445
- var result;
446
- for (var i = 0; i < count; i++) {
447
- result = _this._iterate();
352
+ operation: () => {
353
+ let result;
354
+ for (let i = 0; i < count; i++) {
355
+ result = this._iterate();
448
356
  // Not sure why this is needed
449
357
  if (!result) {
450
358
  break;
@@ -456,11 +364,11 @@ var FDBCursor = /** @class */ (function () {
456
364
  source: this.source,
457
365
  });
458
366
  this._gotValue = false;
459
- };
367
+ }
460
368
  // http://www.w3.org/TR/2015/REC-IndexedDB-20150108/#widl-IDBCursor-continue-void-any-key
461
- FDBCursor.prototype.continue = function (key) {
462
- var effectiveObjectStore = getEffectiveObjectStore(this);
463
- var transaction = effectiveObjectStore.transaction;
369
+ continue(key) {
370
+ const effectiveObjectStore = getEffectiveObjectStore(this);
371
+ const transaction = effectiveObjectStore.transaction;
464
372
  if (transaction._state !== "active") {
465
373
  throw new TransactionInactiveError();
466
374
  }
@@ -476,7 +384,7 @@ var FDBCursor = /** @class */ (function () {
476
384
  }
477
385
  if (key !== undefined) {
478
386
  key = valueToKey(key);
479
- var cmpResult = cmp(key, this._position);
387
+ const cmpResult = cmp(key, this._position);
480
388
  if ((cmpResult <= 0 &&
481
389
  (this.direction === "next" ||
482
390
  this.direction === "nextunique")) ||
@@ -495,11 +403,11 @@ var FDBCursor = /** @class */ (function () {
495
403
  source: this.source,
496
404
  });
497
405
  this._gotValue = false;
498
- };
406
+ }
499
407
  // hthttps://w3c.github.io/IndexedDB/#dom-idbcursor-continueprimarykey
500
- FDBCursor.prototype.continuePrimaryKey = function (key, primaryKey) {
501
- var effectiveObjectStore = getEffectiveObjectStore(this);
502
- var transaction = effectiveObjectStore.transaction;
408
+ continuePrimaryKey(key, primaryKey) {
409
+ const effectiveObjectStore = getEffectiveObjectStore(this);
410
+ const transaction = effectiveObjectStore.transaction;
503
411
  if (transaction._state !== "active") {
504
412
  throw new TransactionInactiveError();
505
413
  }
@@ -522,12 +430,12 @@ var FDBCursor = /** @class */ (function () {
522
430
  throw new DataError();
523
431
  }
524
432
  key = valueToKey(key);
525
- var cmpResult = cmp(key, this._position);
433
+ const cmpResult = cmp(key, this._position);
526
434
  if ((cmpResult === -1 && this.direction === "next") ||
527
435
  (cmpResult === 1 && this.direction === "prev")) {
528
436
  throw new DataError();
529
437
  }
530
- var cmpResult2 = cmp(primaryKey, this._objectStorePosition);
438
+ const cmpResult2 = cmp(primaryKey, this._objectStorePosition);
531
439
  if (cmpResult === 0) {
532
440
  if ((cmpResult2 <= 0 && this.direction === "next") ||
533
441
  (cmpResult2 >= 0 && this.direction === "prev")) {
@@ -543,13 +451,13 @@ var FDBCursor = /** @class */ (function () {
543
451
  source: this.source,
544
452
  });
545
453
  this._gotValue = false;
546
- };
547
- FDBCursor.prototype.delete = function () {
548
- var effectiveObjectStore = getEffectiveObjectStore(this);
549
- var effectiveKey = this.source.hasOwnProperty("_rawIndex")
454
+ }
455
+ delete() {
456
+ const effectiveObjectStore = getEffectiveObjectStore(this);
457
+ const effectiveKey = this.source.hasOwnProperty("_rawIndex")
550
458
  ? this.primaryKey
551
459
  : this._position;
552
- var transaction = effectiveObjectStore.transaction;
460
+ const transaction = effectiveObjectStore.transaction;
553
461
  if (transaction._state !== "active") {
554
462
  throw new TransactionInactiveError();
555
463
  }
@@ -570,10 +478,9 @@ var FDBCursor = /** @class */ (function () {
570
478
  operation: effectiveObjectStore._rawObjectStore.deleteRecord.bind(effectiveObjectStore._rawObjectStore, effectiveKey, transaction._rollbackLog),
571
479
  source: this,
572
480
  });
573
- };
574
- FDBCursor.prototype.toString = function () {
481
+ }
482
+ toString() {
575
483
  return "[object IDBCursor]";
576
- };
577
- return FDBCursor;
578
- }());
484
+ }
485
+ }
579
486
  export default FDBCursor;