dexie 4.4.1 → 4.4.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.
@@ -4,17 +4,20 @@
4
4
  *
5
5
  * By David Fahlander, david.fahlander@gmail.com
6
6
  *
7
- * Version 4.4.1, Wed Mar 25 2026
7
+ * Version 4.4.2, Tue Mar 31 2026
8
8
  *
9
9
  * https://dexie.org
10
10
  *
11
11
  * Apache License Version 2.0, January 2004, http://www.apache.org/licenses/
12
12
  */
13
13
 
14
- const _global = typeof globalThis !== 'undefined' ? globalThis :
15
- typeof self !== 'undefined' ? self :
16
- typeof window !== 'undefined' ? window :
17
- global;
14
+ const _global = typeof globalThis !== 'undefined'
15
+ ? globalThis
16
+ : typeof self !== 'undefined'
17
+ ? self
18
+ : typeof window !== 'undefined'
19
+ ? window
20
+ : global;
18
21
 
19
22
  const keys = Object.keys;
20
23
  const isArray = Array.isArray;
@@ -37,32 +40,38 @@ function hasOwn(obj, prop) {
37
40
  function props(proto, extension) {
38
41
  if (typeof extension === 'function')
39
42
  extension = extension(getProto(proto));
40
- (typeof Reflect === "undefined" ? keys : Reflect.ownKeys)(extension).forEach(key => {
43
+ (typeof Reflect === 'undefined' ? keys : Reflect.ownKeys)(extension).forEach((key) => {
41
44
  setProp(proto, key, extension[key]);
42
45
  });
43
46
  }
44
47
  const defineProperty = Object.defineProperty;
45
48
  function setProp(obj, prop, functionOrGetSet, options) {
46
- defineProperty(obj, prop, extend(functionOrGetSet && hasOwn(functionOrGetSet, "get") && typeof functionOrGetSet.get === 'function' ?
47
- { get: functionOrGetSet.get, set: functionOrGetSet.set, configurable: true } :
48
- { value: functionOrGetSet, configurable: true, writable: true }, options));
49
+ defineProperty(obj, prop, extend(functionOrGetSet &&
50
+ hasOwn(functionOrGetSet, 'get') &&
51
+ typeof functionOrGetSet.get === 'function'
52
+ ? {
53
+ get: functionOrGetSet.get,
54
+ set: functionOrGetSet.set,
55
+ configurable: true,
56
+ }
57
+ : { value: functionOrGetSet, configurable: true, writable: true }, options));
49
58
  }
50
59
  function derive(Child) {
51
60
  return {
52
61
  from: function (Parent) {
53
62
  Child.prototype = Object.create(Parent.prototype);
54
- setProp(Child.prototype, "constructor", Child);
63
+ setProp(Child.prototype, 'constructor', Child);
55
64
  return {
56
- extend: props.bind(null, Child.prototype)
65
+ extend: props.bind(null, Child.prototype),
57
66
  };
58
- }
67
+ },
59
68
  };
60
69
  }
61
70
  const getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
62
71
  function getPropertyDescriptor(obj, prop) {
63
72
  const pd = getOwnPropertyDescriptor(obj, prop);
64
73
  let proto;
65
- return pd || (proto = getProto(obj)) && getPropertyDescriptor(proto, prop);
74
+ return pd || ((proto = getProto(obj)) && getPropertyDescriptor(proto, prop));
66
75
  }
67
76
  const _slice = [].slice;
68
77
  function slice(args, start, end) {
@@ -73,7 +82,7 @@ function override(origFunc, overridedFactory) {
73
82
  }
74
83
  function assert(b) {
75
84
  if (!b)
76
- throw new Error("Assertion Failed");
85
+ throw new Error('Assertion Failed');
77
86
  }
78
87
  function asap$1(fn) {
79
88
  if (_global.setImmediate)
@@ -105,7 +114,9 @@ function getByKeyPath(obj, keyPath) {
105
114
  var period = keyPath.indexOf('.');
106
115
  if (period !== -1) {
107
116
  var innerObj = obj[keyPath.substr(0, period)];
108
- return innerObj == null ? undefined : getByKeyPath(innerObj, keyPath.substr(period + 1));
117
+ return innerObj == null
118
+ ? undefined
119
+ : getByKeyPath(innerObj, keyPath.substr(period + 1));
109
120
  }
110
121
  return undefined;
111
122
  }
@@ -125,7 +136,7 @@ function setByKeyPath(obj, keyPath, value) {
125
136
  if (period !== -1) {
126
137
  var currentKeyPath = keyPath.substr(0, period);
127
138
  var remainingKeyPath = keyPath.substr(period + 1);
128
- if (remainingKeyPath === "")
139
+ if (remainingKeyPath === '')
129
140
  if (value === undefined) {
130
141
  if (isArray(obj) && !isNaN(parseInt(currentKeyPath)))
131
142
  obj.splice(currentKeyPath, 1);
@@ -137,7 +148,7 @@ function setByKeyPath(obj, keyPath, value) {
137
148
  else {
138
149
  var innerObj = obj[currentKeyPath];
139
150
  if (!innerObj || !hasOwn(obj, currentKeyPath))
140
- innerObj = (obj[currentKeyPath] = {});
151
+ innerObj = obj[currentKeyPath] = {};
141
152
  setByKeyPath(innerObj, remainingKeyPath, value);
142
153
  }
143
154
  }
@@ -173,15 +184,20 @@ const concat = [].concat;
173
184
  function flatten(a) {
174
185
  return concat.apply([], a);
175
186
  }
176
- const intrinsicTypeNames = "BigUint64Array,BigInt64Array,Array,Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,FileSystemDirectoryHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey"
177
- .split(',').concat(flatten([8, 16, 32, 64].map(num => ["Int", "Uint", "Float"].map(t => t + num + "Array")))).filter(t => _global[t]);
178
- const intrinsicTypes = new Set(intrinsicTypeNames.map(t => _global[t]));
187
+ const intrinsicTypeNames = 'BigUint64Array,BigInt64Array,Array,Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,FileSystemDirectoryHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey'
188
+ .split(',')
189
+ .concat(flatten([8, 16, 32, 64].map((num) => ['Int', 'Uint', 'Float'].map((t) => t + num + 'Array'))))
190
+ .filter((t) => _global[t]);
191
+ const intrinsicTypes = new Set(intrinsicTypeNames.map((t) => _global[t]));
179
192
  function cloneSimpleObjectTree(o) {
180
193
  const rv = {};
181
194
  for (const k in o)
182
195
  if (hasOwn(o, k)) {
183
196
  const v = o[k];
184
- rv[k] = !v || typeof v !== 'object' || intrinsicTypes.has(v.constructor) ? v : cloneSimpleObjectTree(v);
197
+ rv[k] =
198
+ !v || typeof v !== 'object' || intrinsicTypes.has(v.constructor)
199
+ ? v
200
+ : cloneSimpleObjectTree(v);
185
201
  }
186
202
  return rv;
187
203
  }
@@ -224,13 +240,15 @@ const { toString } = {};
224
240
  function toStringTag(o) {
225
241
  return toString.call(o).slice(8, -1);
226
242
  }
227
- const iteratorSymbol = typeof Symbol !== 'undefined' ?
228
- Symbol.iterator :
229
- '@@iterator';
230
- const getIteratorOf = typeof iteratorSymbol === "symbol" ? function (x) {
231
- var i;
232
- return x != null && (i = x[iteratorSymbol]) && i.apply(x);
233
- } : function () { return null; };
243
+ const iteratorSymbol = typeof Symbol !== 'undefined' ? Symbol.iterator : '@@iterator';
244
+ const getIteratorOf = typeof iteratorSymbol === 'symbol'
245
+ ? function (x) {
246
+ var i;
247
+ return x != null && (i = x[iteratorSymbol]) && i.apply(x);
248
+ }
249
+ : function () {
250
+ return null;
251
+ };
234
252
  function delArrayItem(a, x) {
235
253
  const i = a.indexOf(x);
236
254
  if (i >= 0)
@@ -247,7 +265,7 @@ function getArrayOf(arrayLike) {
247
265
  return [arrayLike];
248
266
  if ((it = getIteratorOf(arrayLike))) {
249
267
  a = [];
250
- while ((x = it.next()), !x.done)
268
+ while (((x = it.next()), !x.done))
251
269
  a.push(x.value);
252
270
  return a;
253
271
  }
@@ -288,7 +306,7 @@ var dexieErrorNames = [
288
306
  'Internal',
289
307
  'DatabaseClosed',
290
308
  'PrematureCommit',
291
- 'ForeignAwait'
309
+ 'ForeignAwait',
292
310
  ];
293
311
  var idbDomErrorNames = [
294
312
  'Unknown',
@@ -304,28 +322,34 @@ var idbDomErrorNames = [
304
322
  'Timeout',
305
323
  'QuotaExceeded',
306
324
  'Syntax',
307
- 'DataClone'
325
+ 'DataClone',
308
326
  ];
309
327
  var errorList = dexieErrorNames.concat(idbDomErrorNames);
310
328
  var defaultTexts = {
311
- VersionChanged: "Database version changed by other database connection",
312
- DatabaseClosed: "Database has been closed",
313
- Abort: "Transaction aborted",
314
- TransactionInactive: "Transaction has already completed or failed",
315
- MissingAPI: "IndexedDB API missing. Please visit https://tinyurl.com/y2uuvskb"
329
+ VersionChanged: 'Database version changed by other database connection',
330
+ DatabaseClosed: 'Database has been closed',
331
+ Abort: 'Transaction aborted',
332
+ TransactionInactive: 'Transaction has already completed or failed',
333
+ MissingAPI: 'IndexedDB API missing. Please visit https://tinyurl.com/y2uuvskb',
316
334
  };
317
335
  function DexieError(name, msg) {
318
336
  this.name = name;
319
337
  this.message = msg;
320
338
  }
321
- derive(DexieError).from(Error).extend({
322
- toString: function () { return this.name + ": " + this.message; }
339
+ derive(DexieError)
340
+ .from(Error)
341
+ .extend({
342
+ toString: function () {
343
+ return this.name + ': ' + this.message;
344
+ },
323
345
  });
324
346
  function getMultiErrorMessage(msg, failures) {
325
- return msg + ". Errors: " + Object.keys(failures)
326
- .map(key => failures[key].toString())
327
- .filter((v, i, s) => s.indexOf(v) === i)
328
- .join('\n');
347
+ return (msg +
348
+ '. Errors: ' +
349
+ Object.keys(failures)
350
+ .map((key) => failures[key].toString())
351
+ .filter((v, i, s) => s.indexOf(v) === i)
352
+ .join('\n'));
329
353
  }
330
354
  function ModifyError(msg, failures, successCount, failedKeys) {
331
355
  this.failures = failures;
@@ -335,16 +359,16 @@ function ModifyError(msg, failures, successCount, failedKeys) {
335
359
  }
336
360
  derive(ModifyError).from(DexieError);
337
361
  function BulkError(msg, failures) {
338
- this.name = "BulkError";
339
- this.failures = Object.keys(failures).map(pos => failures[pos]);
362
+ this.name = 'BulkError';
363
+ this.failures = Object.keys(failures).map((pos) => failures[pos]);
340
364
  this.failuresByPos = failures;
341
365
  this.message = getMultiErrorMessage(msg, this.failures);
342
366
  }
343
367
  derive(BulkError).from(DexieError);
344
- var errnames = errorList.reduce((obj, name) => (obj[name] = name + "Error", obj), {});
368
+ var errnames = errorList.reduce((obj, name) => ((obj[name] = name + 'Error'), obj), {});
345
369
  const BaseException = DexieError;
346
370
  var exceptions = errorList.reduce((obj, name) => {
347
- var fullName = name + "Error";
371
+ var fullName = name + 'Error';
348
372
  function DexieError(msgOrInner, inner) {
349
373
  this.name = fullName;
350
374
  if (!msgOrInner) {
@@ -368,23 +392,30 @@ exceptions.Syntax = SyntaxError;
368
392
  exceptions.Type = TypeError;
369
393
  exceptions.Range = RangeError;
370
394
  var exceptionMap = idbDomErrorNames.reduce((obj, name) => {
371
- obj[name + "Error"] = exceptions[name];
395
+ obj[name + 'Error'] = exceptions[name];
372
396
  return obj;
373
397
  }, {});
374
398
  function mapError(domError, message) {
375
- if (!domError || domError instanceof DexieError || domError instanceof TypeError || domError instanceof SyntaxError || !domError.name || !exceptionMap[domError.name])
399
+ if (!domError ||
400
+ domError instanceof DexieError ||
401
+ domError instanceof TypeError ||
402
+ domError instanceof SyntaxError ||
403
+ !domError.name ||
404
+ !exceptionMap[domError.name])
376
405
  return domError;
377
406
  var rv = new exceptionMap[domError.name](message || domError.message, domError);
378
- if ("stack" in domError) {
379
- setProp(rv, "stack", { get: function () {
407
+ if ('stack' in domError) {
408
+ setProp(rv, 'stack', {
409
+ get: function () {
380
410
  return this.inner.stack;
381
- } });
411
+ },
412
+ });
382
413
  }
383
414
  return rv;
384
415
  }
385
416
  var fullNameExceptions = errorList.reduce((obj, name) => {
386
- if (["Syntax", "Type", "Range"].indexOf(name) === -1)
387
- obj[name + "Error"] = exceptions[name];
417
+ if (['Syntax', 'Type', 'Range'].indexOf(name) === -1)
418
+ obj[name + 'Error'] = exceptions[name];
388
419
  return obj;
389
420
  }, {});
390
421
  fullNameExceptions.ModifyError = ModifyError;
@@ -392,7 +423,9 @@ fullNameExceptions.DexieError = DexieError;
392
423
  fullNameExceptions.BulkError = BulkError;
393
424
 
394
425
  function nop() { }
395
- function mirror(val) { return val; }
426
+ function mirror(val) {
427
+ return val;
428
+ }
396
429
  function pureFunctionChain(f1, f2) {
397
430
  if (f1 == null || f1 === mirror)
398
431
  return f2;
@@ -419,7 +452,9 @@ function hookCreatingChain(f1, f2) {
419
452
  this.onerror = null;
420
453
  var res2 = f2.apply(this, arguments);
421
454
  if (onsuccess)
422
- this.onsuccess = this.onsuccess ? callBoth(onsuccess, this.onsuccess) : onsuccess;
455
+ this.onsuccess = this.onsuccess
456
+ ? callBoth(onsuccess, this.onsuccess)
457
+ : onsuccess;
423
458
  if (onerror)
424
459
  this.onerror = this.onerror ? callBoth(onerror, this.onerror) : onerror;
425
460
  return res2 !== undefined ? res2 : res;
@@ -435,7 +470,9 @@ function hookDeletingChain(f1, f2) {
435
470
  this.onsuccess = this.onerror = null;
436
471
  f2.apply(this, arguments);
437
472
  if (onsuccess)
438
- this.onsuccess = this.onsuccess ? callBoth(onsuccess, this.onsuccess) : onsuccess;
473
+ this.onsuccess = this.onsuccess
474
+ ? callBoth(onsuccess, this.onsuccess)
475
+ : onsuccess;
439
476
  if (onerror)
440
477
  this.onerror = this.onerror ? callBoth(onerror, this.onerror) : onerror;
441
478
  };
@@ -452,12 +489,16 @@ function hookUpdatingChain(f1, f2) {
452
489
  this.onerror = null;
453
490
  var res2 = f2.apply(this, arguments);
454
491
  if (onsuccess)
455
- this.onsuccess = this.onsuccess ? callBoth(onsuccess, this.onsuccess) : onsuccess;
492
+ this.onsuccess = this.onsuccess
493
+ ? callBoth(onsuccess, this.onsuccess)
494
+ : onsuccess;
456
495
  if (onerror)
457
496
  this.onerror = this.onerror ? callBoth(onerror, this.onerror) : onerror;
458
- return res === undefined ?
459
- (res2 === undefined ? undefined : res2) :
460
- (extend(res, res2));
497
+ return res === undefined
498
+ ? res2 === undefined
499
+ ? undefined
500
+ : res2
501
+ : extend(res, res2);
461
502
  };
462
503
  }
463
504
  function reverseStoppableEventChain(f1, f2) {
@@ -493,18 +534,14 @@ function setDebug(value, filter) {
493
534
  }
494
535
 
495
536
  var INTERNAL = {};
496
- const ZONE_ECHO_LIMIT = 100, [resolvedNativePromise, nativePromiseProto, resolvedGlobalPromise] = typeof Promise === 'undefined' ?
497
- [] :
498
- (() => {
537
+ const ZONE_ECHO_LIMIT = 100, [resolvedNativePromise, nativePromiseProto, resolvedGlobalPromise] = typeof Promise === 'undefined'
538
+ ? []
539
+ : (() => {
499
540
  let globalP = Promise.resolve();
500
541
  if (typeof crypto === 'undefined' || !crypto.subtle)
501
542
  return [globalP, getProto(globalP), globalP];
502
- const nativeP = crypto.subtle.digest("SHA-512", new Uint8Array([0]));
503
- return [
504
- nativeP,
505
- getProto(nativeP),
506
- globalP
507
- ];
543
+ const nativeP = crypto.subtle.digest('SHA-512', new Uint8Array([0]));
544
+ return [nativeP, getProto(nativeP), globalP];
508
545
  })(), nativePromiseThen = nativePromiseProto && nativePromiseProto.then;
509
546
  const NativePromise = resolvedNativePromise && resolvedNativePromise.constructor;
510
547
  const patchGlobalPromise = !!resolvedGlobalPromise;
@@ -531,7 +568,7 @@ var globalPSD = {
531
568
  onunhandled: nop,
532
569
  pgp: false,
533
570
  env: {},
534
- finalize: nop
571
+ finalize: nop,
535
572
  };
536
573
  var PSD = globalPSD;
537
574
  var microtickQueue = [];
@@ -574,15 +611,15 @@ const thenProp = {
574
611
  return then;
575
612
  },
576
613
  set: function (value) {
577
- setProp(this, 'then', value && value.prototype === INTERNAL ?
578
- thenProp :
579
- {
614
+ setProp(this, 'then', value && value.prototype === INTERNAL
615
+ ? thenProp
616
+ : {
580
617
  get: function () {
581
618
  return value;
582
619
  },
583
- set: thenProp.set
620
+ set: thenProp.set,
584
621
  });
585
- }
622
+ },
586
623
  };
587
624
  props(DexiePromise.prototype, {
588
625
  then: thenProp,
@@ -593,25 +630,27 @@ props(DexiePromise.prototype, {
593
630
  if (arguments.length === 1)
594
631
  return this.then(null, onRejected);
595
632
  var type = arguments[0], handler = arguments[1];
596
- return typeof type === 'function' ? this.then(null, err =>
597
- err instanceof type ? handler(err) : PromiseReject(err))
598
- : this.then(null, err =>
633
+ return typeof type === 'function'
634
+ ? this.then(null, (err) =>
635
+ err instanceof type ? handler(err) : PromiseReject(err))
636
+ : this.then(null, (err) =>
599
637
  err && err.name === type ? handler(err) : PromiseReject(err));
600
638
  },
601
639
  finally: function (onFinally) {
602
- return this.then(value => {
640
+ return this.then((value) => {
603
641
  return DexiePromise.resolve(onFinally()).then(() => value);
604
- }, err => {
642
+ }, (err) => {
605
643
  return DexiePromise.resolve(onFinally()).then(() => PromiseReject(err));
606
644
  });
607
645
  },
608
646
  timeout: function (ms, msg) {
609
- return ms < Infinity ?
610
- new DexiePromise((resolve, reject) => {
647
+ return ms < Infinity
648
+ ? new DexiePromise((resolve, reject) => {
611
649
  var handle = setTimeout(() => reject(new exceptions.Timeout(msg)), ms);
612
650
  this.then(resolve, reject).finally(clearTimeout.bind(null, handle));
613
- }) : this;
614
- }
651
+ })
652
+ : this;
653
+ },
615
654
  });
616
655
  if (typeof Symbol !== 'undefined' && Symbol.toStringTag)
617
656
  setProp(DexiePromise.prototype, Symbol.toStringTag, 'Dexie.Promise');
@@ -625,20 +664,21 @@ function Listener(onFulfilled, onRejected, resolve, reject, zone) {
625
664
  }
626
665
  props(DexiePromise, {
627
666
  all: function () {
628
- var values = getArrayOf.apply(null, arguments)
667
+ var values = getArrayOf
668
+ .apply(null, arguments)
629
669
  .map(onPossibleParallellAsync);
630
670
  return new DexiePromise(function (resolve, reject) {
631
671
  if (values.length === 0)
632
672
  resolve([]);
633
673
  var remaining = values.length;
634
- values.forEach((a, i) => DexiePromise.resolve(a).then(x => {
674
+ values.forEach((a, i) => DexiePromise.resolve(a).then((x) => {
635
675
  values[i] = x;
636
676
  if (!--remaining)
637
677
  resolve(values);
638
678
  }, reject));
639
679
  });
640
680
  },
641
- resolve: value => {
681
+ resolve: (value) => {
642
682
  if (value instanceof DexiePromise)
643
683
  return value;
644
684
  if (value && typeof value.then === 'function')
@@ -650,25 +690,31 @@ props(DexiePromise, {
650
690
  },
651
691
  reject: PromiseReject,
652
692
  race: function () {
653
- var values = getArrayOf.apply(null, arguments).map(onPossibleParallellAsync);
693
+ var values = getArrayOf
694
+ .apply(null, arguments)
695
+ .map(onPossibleParallellAsync);
654
696
  return new DexiePromise((resolve, reject) => {
655
- values.map(value => DexiePromise.resolve(value).then(resolve, reject));
697
+ values.map((value) => DexiePromise.resolve(value).then(resolve, reject));
656
698
  });
657
699
  },
658
700
  PSD: {
659
701
  get: () => PSD,
660
- set: value => PSD = value
702
+ set: (value) => (PSD = value),
661
703
  },
662
704
  totalEchoes: { get: () => totalEchoes },
663
705
  newPSD: newScope,
664
706
  usePSD: usePSD,
665
707
  scheduler: {
666
708
  get: () => asap,
667
- set: value => { asap = value; }
709
+ set: (value) => {
710
+ asap = value;
711
+ },
668
712
  },
669
713
  rejectionMapper: {
670
714
  get: () => rejectionMapper,
671
- set: value => { rejectionMapper = value; }
715
+ set: (value) => {
716
+ rejectionMapper = value;
717
+ },
672
718
  },
673
719
  follow: (fn, zoneProps) => {
674
720
  return new DexiePromise((resolve, reject) => {
@@ -678,36 +724,43 @@ props(DexiePromise, {
678
724
  psd.onunhandled = reject;
679
725
  psd.finalize = callBoth(function () {
680
726
  run_at_end_of_this_or_next_physical_tick(() => {
681
- this.unhandleds.length === 0 ? resolve() : reject(this.unhandleds[0]);
727
+ this.unhandleds.length === 0
728
+ ? resolve()
729
+ : reject(this.unhandleds[0]);
682
730
  });
683
731
  }, psd.finalize);
684
732
  fn();
685
733
  }, zoneProps, resolve, reject);
686
734
  });
687
- }
735
+ },
688
736
  });
689
737
  if (NativePromise) {
690
738
  if (NativePromise.allSettled)
691
- setProp(DexiePromise, "allSettled", function () {
692
- const possiblePromises = getArrayOf.apply(null, arguments).map(onPossibleParallellAsync);
693
- return new DexiePromise(resolve => {
739
+ setProp(DexiePromise, 'allSettled', function () {
740
+ const possiblePromises = getArrayOf
741
+ .apply(null, arguments)
742
+ .map(onPossibleParallellAsync);
743
+ return new DexiePromise((resolve) => {
694
744
  if (possiblePromises.length === 0)
695
745
  resolve([]);
696
746
  let remaining = possiblePromises.length;
697
747
  const results = new Array(remaining);
698
- possiblePromises.forEach((p, i) => DexiePromise.resolve(p).then(value => results[i] = { status: "fulfilled", value }, reason => results[i] = { status: "rejected", reason })
748
+ possiblePromises.forEach((p, i) => DexiePromise.resolve(p)
749
+ .then((value) => (results[i] = { status: 'fulfilled', value }), (reason) => (results[i] = { status: 'rejected', reason }))
699
750
  .then(() => --remaining || resolve(results)));
700
751
  });
701
752
  });
702
753
  if (NativePromise.any && typeof AggregateError !== 'undefined')
703
- setProp(DexiePromise, "any", function () {
704
- const possiblePromises = getArrayOf.apply(null, arguments).map(onPossibleParallellAsync);
754
+ setProp(DexiePromise, 'any', function () {
755
+ const possiblePromises = getArrayOf
756
+ .apply(null, arguments)
757
+ .map(onPossibleParallellAsync);
705
758
  return new DexiePromise((resolve, reject) => {
706
759
  if (possiblePromises.length === 0)
707
760
  reject(new AggregateError([]));
708
761
  let remaining = possiblePromises.length;
709
762
  const failures = new Array(remaining);
710
- possiblePromises.forEach((p, i) => DexiePromise.resolve(p).then(value => resolve(value), failure => {
763
+ possiblePromises.forEach((p, i) => DexiePromise.resolve(p).then((value) => resolve(value), (failure) => {
711
764
  failures[i] = failure;
712
765
  if (!--remaining)
713
766
  reject(new AggregateError(failures));
@@ -719,7 +772,7 @@ if (NativePromise) {
719
772
  }
720
773
  function executePromiseTask(promise, fn) {
721
774
  try {
722
- fn(value => {
775
+ fn((value) => {
723
776
  if (promise._state !== null)
724
777
  return;
725
778
  if (value === promise)
@@ -727,9 +780,9 @@ function executePromiseTask(promise, fn) {
727
780
  var shouldExecuteTick = promise._lib && beginMicroTickScope();
728
781
  if (value && typeof value.then === 'function') {
729
782
  executePromiseTask(promise, (resolve, reject) => {
730
- value instanceof DexiePromise ?
731
- value._then(resolve, reject) :
732
- value.then(resolve, reject);
783
+ value instanceof DexiePromise
784
+ ? value._then(resolve, reject)
785
+ : value.then(resolve, reject);
733
786
  });
734
787
  }
735
788
  else {
@@ -792,7 +845,10 @@ function callListener(cb, promise, listener) {
792
845
  var ret, value = promise._value;
793
846
  if (!promise._state && rejectingErrors.length)
794
847
  rejectingErrors = [];
795
- ret = debug && promise._consoleTask ? promise._consoleTask.run(() => cb(value)) : cb(value);
848
+ ret =
849
+ debug && promise._consoleTask
850
+ ? promise._consoleTask.run(() => cb(value))
851
+ : cb(value);
796
852
  if (!promise._state && rejectingErrors.indexOf(value) === -1) {
797
853
  markErrorAsHandled(promise);
798
854
  }
@@ -837,7 +893,7 @@ function endMicroTickScope() {
837
893
  function finalizePhysicalTick() {
838
894
  var unhandledErrs = unhandledErrors;
839
895
  unhandledErrors = [];
840
- unhandledErrs.forEach(p => {
896
+ unhandledErrs.forEach((p) => {
841
897
  p._PSD.onunhandled.call(null, p._value, p);
842
898
  });
843
899
  var finalizers = tickFinalizers.slice(0);
@@ -858,7 +914,7 @@ function run_at_end_of_this_or_next_physical_tick(fn) {
858
914
  }, []);
859
915
  }
860
916
  function addPossiblyUnhandledError(promise) {
861
- if (!unhandledErrors.some(p => p._value === promise._value))
917
+ if (!unhandledErrors.some((p) => p._value === promise._value))
862
918
  unhandledErrors.push(promise);
863
919
  }
864
920
  function markErrorAsHandled(promise) {
@@ -903,16 +959,22 @@ function newScope(fn, props, a1, a2) {
903
959
  psd.global = false;
904
960
  psd.id = ++zone_id_counter;
905
961
  globalPSD.env;
906
- psd.env = patchGlobalPromise ? {
907
- Promise: DexiePromise,
908
- PromiseProp: { value: DexiePromise, configurable: true, writable: true },
909
- all: DexiePromise.all,
910
- race: DexiePromise.race,
911
- allSettled: DexiePromise.allSettled,
912
- any: DexiePromise.any,
913
- resolve: DexiePromise.resolve,
914
- reject: DexiePromise.reject,
915
- } : {};
962
+ psd.env = patchGlobalPromise
963
+ ? {
964
+ Promise: DexiePromise,
965
+ PromiseProp: {
966
+ value: DexiePromise,
967
+ configurable: true,
968
+ writable: true,
969
+ },
970
+ all: DexiePromise.all,
971
+ race: DexiePromise.race,
972
+ allSettled: DexiePromise.allSettled,
973
+ any: DexiePromise.any,
974
+ resolve: DexiePromise.resolve,
975
+ reject: DexiePromise.reject,
976
+ }
977
+ : {};
916
978
  if (props)
917
979
  extend(psd, props);
918
980
  ++parent.ref;
@@ -943,12 +1005,14 @@ if (('' + nativePromiseThen).indexOf('[native code]') === -1) {
943
1005
  incrementExpectedAwaits = decrementExpectedAwaits = nop;
944
1006
  }
945
1007
  function onPossibleParallellAsync(possiblePromise) {
946
- if (task.echoes && possiblePromise && possiblePromise.constructor === NativePromise) {
1008
+ if (task.echoes &&
1009
+ possiblePromise &&
1010
+ possiblePromise.constructor === NativePromise) {
947
1011
  incrementExpectedAwaits();
948
- return possiblePromise.then(x => {
1012
+ return possiblePromise.then((x) => {
949
1013
  decrementExpectedAwaits();
950
1014
  return x;
951
- }, e => {
1015
+ }, (e) => {
952
1016
  decrementExpectedAwaits();
953
1017
  return rejection(e);
954
1018
  });
@@ -970,7 +1034,9 @@ function zoneLeaveEcho() {
970
1034
  }
971
1035
  function switchToZone(targetZone, bEnteringZone) {
972
1036
  var currentZone = PSD;
973
- if (bEnteringZone ? task.echoes && (!zoneEchoes++ || targetZone !== PSD) : zoneEchoes && (!--zoneEchoes || targetZone !== PSD)) {
1037
+ if (bEnteringZone
1038
+ ? task.echoes && (!zoneEchoes++ || targetZone !== PSD)
1039
+ : zoneEchoes && (!--zoneEchoes || targetZone !== PSD)) {
974
1040
  queueMicrotask(bEnteringZone ? zoneEnterEcho.bind(null, targetZone) : zoneLeaveEcho);
975
1041
  }
976
1042
  if (targetZone === PSD)
@@ -996,16 +1062,18 @@ function switchToZone(targetZone, bEnteringZone) {
996
1062
  }
997
1063
  function snapShot() {
998
1064
  var GlobalPromise = _global.Promise;
999
- return patchGlobalPromise ? {
1000
- Promise: GlobalPromise,
1001
- PromiseProp: Object.getOwnPropertyDescriptor(_global, "Promise"),
1002
- all: GlobalPromise.all,
1003
- race: GlobalPromise.race,
1004
- allSettled: GlobalPromise.allSettled,
1005
- any: GlobalPromise.any,
1006
- resolve: GlobalPromise.resolve,
1007
- reject: GlobalPromise.reject,
1008
- } : {};
1065
+ return patchGlobalPromise
1066
+ ? {
1067
+ Promise: GlobalPromise,
1068
+ PromiseProp: Object.getOwnPropertyDescriptor(_global, 'Promise'),
1069
+ all: GlobalPromise.all,
1070
+ race: GlobalPromise.race,
1071
+ allSettled: GlobalPromise.allSettled,
1072
+ any: GlobalPromise.any,
1073
+ resolve: GlobalPromise.resolve,
1074
+ reject: GlobalPromise.reject,
1075
+ }
1076
+ : {};
1009
1077
  }
1010
1078
  function usePSD(psd, fn, a1, a2, a3) {
1011
1079
  var outerScope = PSD;
@@ -1018,20 +1086,22 @@ function usePSD(psd, fn, a1, a2, a3) {
1018
1086
  }
1019
1087
  }
1020
1088
  function nativeAwaitCompatibleWrap(fn, zone, possibleAwait, cleanup) {
1021
- return typeof fn !== 'function' ? fn : function () {
1022
- var outerZone = PSD;
1023
- if (possibleAwait)
1024
- incrementExpectedAwaits();
1025
- switchToZone(zone, true);
1026
- try {
1027
- return fn.apply(this, arguments);
1028
- }
1029
- finally {
1030
- switchToZone(outerZone, false);
1031
- if (cleanup)
1032
- queueMicrotask(decrementExpectedAwaits);
1033
- }
1034
- };
1089
+ return typeof fn !== 'function'
1090
+ ? fn
1091
+ : function () {
1092
+ var outerZone = PSD;
1093
+ if (possibleAwait)
1094
+ incrementExpectedAwaits();
1095
+ switchToZone(zone, true);
1096
+ try {
1097
+ return fn.apply(this, arguments);
1098
+ }
1099
+ finally {
1100
+ switchToZone(outerZone, false);
1101
+ if (cleanup)
1102
+ queueMicrotask(decrementExpectedAwaits);
1103
+ }
1104
+ };
1035
1105
  }
1036
1106
  function execInGlobalContext(cb) {
1037
1107
  if (Promise === NativePromise && task.echoes === 0) {
@@ -1049,7 +1119,7 @@ function execInGlobalContext(cb) {
1049
1119
  var rejection = DexiePromise.reject;
1050
1120
 
1051
1121
  function tempTransaction(db, mode, storeNames, fn) {
1052
- if (!db.idbdb || (!db._state.openComplete && (!PSD.letThrough && !db._vip))) {
1122
+ if (!db.idbdb || (!db._state.openComplete && !PSD.letThrough && !db._vip)) {
1053
1123
  if (db._state.openComplete) {
1054
1124
  return rejection(new exceptions.DatabaseClosed(db._state.dbOpenError));
1055
1125
  }
@@ -1067,45 +1137,53 @@ function tempTransaction(db, mode, storeNames, fn) {
1067
1137
  db._state.PR1398_maxLoop = 3;
1068
1138
  }
1069
1139
  catch (ex) {
1070
- if (ex.name === errnames.InvalidState && db.isOpen() && --db._state.PR1398_maxLoop > 0) {
1140
+ if (ex.name === errnames.InvalidState &&
1141
+ db.isOpen() &&
1142
+ --db._state.PR1398_maxLoop > 0) {
1071
1143
  console.warn('Dexie: Need to reopen db');
1072
1144
  db.close({ disableAutoOpen: false });
1073
1145
  return db.open().then(() => tempTransaction(db, mode, storeNames, fn));
1074
1146
  }
1075
1147
  return rejection(ex);
1076
1148
  }
1077
- return trans._promise(mode, (resolve, reject) => {
1149
+ return trans
1150
+ ._promise(mode, (resolve, reject) => {
1078
1151
  return newScope(() => {
1079
1152
  PSD.trans = trans;
1080
1153
  return fn(resolve, reject, trans);
1081
1154
  });
1082
- }).then(result => {
1155
+ })
1156
+ .then((result) => {
1083
1157
  if (mode === 'readwrite')
1084
1158
  try {
1085
1159
  trans.idbtrans.commit();
1086
1160
  }
1087
1161
  catch { }
1088
- return mode === 'readonly' ? result : trans._completion.then(() => result);
1162
+ return mode === 'readonly'
1163
+ ? result
1164
+ : trans._completion.then(() => result);
1089
1165
  });
1090
1166
  }
1091
1167
  }
1092
1168
 
1093
- const DEXIE_VERSION = '4.4.1';
1169
+ const DEXIE_VERSION = '4.4.2';
1094
1170
  const maxString = String.fromCharCode(65535);
1095
1171
  const minKey = -Infinity;
1096
- const INVALID_KEY_ARGUMENT = "Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.";
1097
- const STRING_EXPECTED = "String expected.";
1172
+ const INVALID_KEY_ARGUMENT = 'Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.';
1173
+ const STRING_EXPECTED = 'String expected.';
1098
1174
  const DEFAULT_MAX_CONNECTIONS = 1000;
1099
1175
  const DBNAMES_DB = '__dbnames';
1100
1176
  const READONLY = 'readonly';
1101
1177
  const READWRITE = 'readwrite';
1102
1178
 
1103
1179
  function combine(filter1, filter2) {
1104
- return filter1 ?
1105
- filter2 ?
1106
- function () { return filter1.apply(this, arguments) && filter2.apply(this, arguments); } :
1107
- filter1 :
1108
- filter2;
1180
+ return filter1
1181
+ ? filter2
1182
+ ? function () {
1183
+ return (filter1.apply(this, arguments) && filter2.apply(this, arguments));
1184
+ }
1185
+ : filter1
1186
+ : filter2;
1109
1187
  }
1110
1188
 
1111
1189
  const AnyRange = {
@@ -1113,13 +1191,13 @@ const AnyRange = {
1113
1191
  lower: -Infinity,
1114
1192
  lowerOpen: false,
1115
1193
  upper: [[]],
1116
- upperOpen: false
1194
+ upperOpen: false,
1117
1195
  };
1118
1196
 
1119
1197
  function workaroundForUndefinedPrimKey(keyPath) {
1120
- return typeof keyPath === "string" && !/\./.test(keyPath)
1198
+ return typeof keyPath === 'string' && !/\./.test(keyPath)
1121
1199
  ? (obj) => {
1122
- if (obj[keyPath] === undefined && (keyPath in obj)) {
1200
+ if (obj[keyPath] === undefined && keyPath in obj) {
1123
1201
  obj = deepClone(obj);
1124
1202
  delete obj[keyPath];
1125
1203
  }
@@ -1221,7 +1299,7 @@ function builtInDeletionTrigger(table, keys, res) {
1221
1299
 
1222
1300
  class PropModification {
1223
1301
  execute(value) {
1224
- const spec = this["@@propmod"];
1302
+ const spec = this['@@propmod'];
1225
1303
  if (spec.add !== undefined) {
1226
1304
  const term = spec.add;
1227
1305
  if (isArray(term)) {
@@ -1242,7 +1320,9 @@ class PropModification {
1242
1320
  if (spec.remove !== undefined) {
1243
1321
  const subtrahend = spec.remove;
1244
1322
  if (isArray(subtrahend)) {
1245
- return isArray(value) ? value.filter(item => !subtrahend.includes(item)).sort() : [];
1323
+ return isArray(value)
1324
+ ? value.filter((item) => !subtrahend.includes(item)).sort()
1325
+ : [];
1246
1326
  }
1247
1327
  if (typeof subtrahend === 'number')
1248
1328
  return Number(value) - subtrahend;
@@ -1257,13 +1337,15 @@ class PropModification {
1257
1337
  throw new TypeError(`Invalid subtrahend ${subtrahend}`);
1258
1338
  }
1259
1339
  const prefixToReplace = spec.replacePrefix?.[0];
1260
- if (prefixToReplace && typeof value === 'string' && value.startsWith(prefixToReplace)) {
1340
+ if (prefixToReplace &&
1341
+ typeof value === 'string' &&
1342
+ value.startsWith(prefixToReplace)) {
1261
1343
  return spec.replacePrefix[1] + value.substring(prefixToReplace.length);
1262
1344
  }
1263
1345
  return value;
1264
1346
  }
1265
1347
  constructor(spec) {
1266
- this["@@propmod"] = spec;
1348
+ this['@@propmod'] = spec;
1267
1349
  }
1268
1350
  }
1269
1351
 
@@ -1291,22 +1373,25 @@ class Table {
1291
1373
  _trans(mode, fn, writeLocked) {
1292
1374
  const trans = this._tx || PSD.trans;
1293
1375
  const tableName = this.name;
1294
- const task = debug && typeof console !== 'undefined' && console.createTask && console.createTask(`Dexie: ${mode === 'readonly' ? 'read' : 'write'} ${this.name}`);
1376
+ const task = debug &&
1377
+ typeof console !== 'undefined' &&
1378
+ console.createTask &&
1379
+ console.createTask(`Dexie: ${mode === 'readonly' ? 'read' : 'write'} ${this.name}`);
1295
1380
  function checkTableInTransaction(resolve, reject, trans) {
1296
1381
  if (!trans.schema[tableName])
1297
- throw new exceptions.NotFound("Table " + tableName + " not part of transaction");
1382
+ throw new exceptions.NotFound('Table ' + tableName + ' not part of transaction');
1298
1383
  return fn(trans.idbtrans, trans);
1299
1384
  }
1300
1385
  const wasRootExec = beginMicroTickScope();
1301
1386
  try {
1302
- let p = trans && trans.db._novip === this.db._novip ?
1303
- trans === PSD.trans ?
1304
- trans._promise(mode, checkTableInTransaction, writeLocked) :
1305
- newScope(() => trans._promise(mode, checkTableInTransaction, writeLocked), { trans: trans, transless: PSD.transless || PSD }) :
1306
- tempTransaction(this.db, mode, [this.name], checkTableInTransaction);
1387
+ let p = trans && trans.db._novip === this.db._novip
1388
+ ? trans === PSD.trans
1389
+ ? trans._promise(mode, checkTableInTransaction, writeLocked)
1390
+ : newScope(() => trans._promise(mode, checkTableInTransaction, writeLocked), { trans: trans, transless: PSD.transless || PSD })
1391
+ : tempTransaction(this.db, mode, [this.name], checkTableInTransaction);
1307
1392
  if (task) {
1308
1393
  p._consoleTask = task;
1309
- p = p.catch(err => {
1394
+ p = p.catch((err) => {
1310
1395
  console.trace(err);
1311
1396
  return rejection(err);
1312
1397
  });
@@ -1324,8 +1409,9 @@ class Table {
1324
1409
  if (keyOrCrit == null)
1325
1410
  return rejection(new exceptions.Type(`Invalid argument to Table.get()`));
1326
1411
  return this._trans('readonly', (trans) => {
1327
- return this.core.get({ trans, key: keyOrCrit })
1328
- .then(res => this.hook.reading.fire(res));
1412
+ return this.core
1413
+ .get({ trans, key: keyOrCrit })
1414
+ .then((res) => this.hook.reading.fire(res));
1329
1415
  }).then(cb);
1330
1416
  }
1331
1417
  where(indexOrCrit) {
@@ -1335,12 +1421,12 @@ class Table {
1335
1421
  return new this.db.WhereClause(this, `[${indexOrCrit.join('+')}]`);
1336
1422
  const keyPaths = keys(indexOrCrit);
1337
1423
  if (keyPaths.length === 1)
1338
- return this
1339
- .where(keyPaths[0])
1340
- .equals(indexOrCrit[keyPaths[0]]);
1341
- const compoundIndex = this.schema.indexes.concat(this.schema.primKey).filter(ix => {
1424
+ return this.where(keyPaths[0]).equals(indexOrCrit[keyPaths[0]]);
1425
+ const compoundIndex = this.schema.indexes
1426
+ .concat(this.schema.primKey)
1427
+ .filter((ix) => {
1342
1428
  if (ix.compound &&
1343
- keyPaths.every(keyPath => ix.keyPath.indexOf(keyPath) >= 0)) {
1429
+ keyPaths.every((keyPath) => ix.keyPath.indexOf(keyPath) >= 0)) {
1344
1430
  for (let i = 0; i < keyPaths.length; ++i) {
1345
1431
  if (keyPaths.indexOf(ix.keyPath[i]) === -1)
1346
1432
  return false;
@@ -1348,12 +1434,11 @@ class Table {
1348
1434
  return true;
1349
1435
  }
1350
1436
  return false;
1351
- }).sort((a, b) => a.keyPath.length - b.keyPath.length)[0];
1437
+ })
1438
+ .sort((a, b) => a.keyPath.length - b.keyPath.length)[0];
1352
1439
  if (compoundIndex && this.db._maxKey !== maxString) {
1353
1440
  const keyPathsInValidOrder = compoundIndex.keyPath.slice(0, keyPaths.length);
1354
- return this
1355
- .where(keyPathsInValidOrder)
1356
- .equals(keyPathsInValidOrder.map(kp => indexOrCrit[kp]));
1441
+ return this.where(keyPathsInValidOrder).equals(keyPathsInValidOrder.map((kp) => indexOrCrit[kp]));
1357
1442
  }
1358
1443
  if (!compoundIndex && debug)
1359
1444
  console.warn(`The query ${JSON.stringify(indexOrCrit)} on ${this.name} would benefit from a ` +
@@ -1367,21 +1452,24 @@ class Table {
1367
1452
  const value = indexOrCrit[keyPath];
1368
1453
  return [
1369
1454
  prevIndex || index,
1370
- prevIndex || !index ?
1371
- combine(prevFilterFn, index && index.multi ?
1372
- x => {
1455
+ prevIndex || !index
1456
+ ? combine(prevFilterFn, index && index.multi
1457
+ ? (x) => {
1373
1458
  const prop = getByKeyPath(x, keyPath);
1374
- return isArray(prop) && prop.some(item => equals(value, item));
1375
- } : x => equals(value, getByKeyPath(x, keyPath)))
1376
- : prevFilterFn
1459
+ return (isArray(prop) &&
1460
+ prop.some((item) => equals(value, item)));
1461
+ }
1462
+ : (x) => equals(value, getByKeyPath(x, keyPath)))
1463
+ : prevFilterFn,
1377
1464
  ];
1378
1465
  }, [null, null]);
1379
- return idx ?
1380
- this.where(idx.name).equals(indexOrCrit[idx.keyPath])
1381
- .filter(filterFunction) :
1382
- compoundIndex ?
1383
- this.filter(filterFunction) :
1384
- this.where(keyPaths).equals('');
1466
+ return idx
1467
+ ? this.where(idx.name)
1468
+ .equals(indexOrCrit[idx.keyPath])
1469
+ .filter(filterFunction)
1470
+ : compoundIndex
1471
+ ? this.filter(filterFunction)
1472
+ : this.where(keyPaths).equals('');
1385
1473
  }
1386
1474
  filter(filterFunction) {
1387
1475
  return this.toCollection().and(filterFunction);
@@ -1405,9 +1493,7 @@ class Table {
1405
1493
  return new this.db.Collection(new this.db.WhereClause(this));
1406
1494
  }
1407
1495
  orderBy(index) {
1408
- return new this.db.Collection(new this.db.WhereClause(this, isArray(index) ?
1409
- `[${index.join('+')}]` :
1410
- index));
1496
+ return new this.db.Collection(new this.db.WhereClause(this, isArray(index) ? `[${index.join('+')}]` : index));
1411
1497
  }
1412
1498
  reverse() {
1413
1499
  return this.toCollection().reverse();
@@ -1417,13 +1503,17 @@ class Table {
1417
1503
  this.schema.mappedClass = constructor;
1418
1504
  if (constructor.prototype instanceof Entity) {
1419
1505
  constructor = class extends constructor {
1420
- get db() { return db; }
1421
- table() { return tableName; }
1506
+ get db() {
1507
+ return db;
1508
+ }
1509
+ table() {
1510
+ return tableName;
1511
+ }
1422
1512
  };
1423
1513
  }
1424
1514
  const inheritedProps = new Set();
1425
1515
  for (let proto = constructor.prototype; proto; proto = getProto(proto)) {
1426
- Object.getOwnPropertyNames(proto).forEach(propName => inheritedProps.add(propName));
1516
+ Object.getOwnPropertyNames(proto).forEach((propName) => inheritedProps.add(propName));
1427
1517
  }
1428
1518
  const readHook = (obj) => {
1429
1519
  if (!obj)
@@ -1441,7 +1531,7 @@ class Table {
1441
1531
  this.hook.reading.unsubscribe(this.schema.readHook);
1442
1532
  }
1443
1533
  this.schema.readHook = readHook;
1444
- this.hook("reading", readHook);
1534
+ this.hook('reading', readHook);
1445
1535
  return constructor;
1446
1536
  }
1447
1537
  defineClass() {
@@ -1456,10 +1546,16 @@ class Table {
1456
1546
  if (keyPath && auto) {
1457
1547
  objToAdd = workaroundForUndefinedPrimKey(keyPath)(obj);
1458
1548
  }
1459
- return this._trans('readwrite', trans => {
1460
- return this.core.mutate({ trans, type: 'add', keys: key != null ? [key] : null, values: [objToAdd] });
1461
- }).then(res => res.numFailures ? DexiePromise.reject(res.failures[0]) : res.lastResult)
1462
- .then(lastResult => {
1549
+ return this._trans('readwrite', (trans) => {
1550
+ return this.core.mutate({
1551
+ trans,
1552
+ type: 'add',
1553
+ keys: key != null ? [key] : null,
1554
+ values: [objToAdd],
1555
+ });
1556
+ })
1557
+ .then((res) => res.numFailures ? DexiePromise.reject(res.failures[0]) : res.lastResult)
1558
+ .then((lastResult) => {
1463
1559
  if (keyPath) {
1464
1560
  try {
1465
1561
  setByKeyPath(obj, keyPath, lastResult);
@@ -1471,20 +1567,22 @@ class Table {
1471
1567
  }
1472
1568
  upsert(key, modifications) {
1473
1569
  const { keyPath } = this.schema.primKey;
1474
- return this._trans('readwrite', trans => {
1475
- return this.core.get({ trans, key }).then(existing => {
1570
+ return this._trans('readwrite', (trans) => {
1571
+ return this.core.get({ trans, key }).then((existing) => {
1476
1572
  const obj = existing ?? {};
1477
1573
  applyUpdateSpec(obj, modifications);
1478
1574
  if (keyPath)
1479
1575
  setByKeyPath(obj, keyPath, key);
1480
- return this.core.mutate({
1576
+ return this.core
1577
+ .mutate({
1481
1578
  trans,
1482
1579
  type: 'put',
1483
1580
  values: [obj],
1484
1581
  keys: [key],
1485
1582
  upsert: true,
1486
- updates: { keys: [key], changeSpecs: [modifications] }
1487
- }).then(res => res.numFailures ? DexiePromise.reject(res.failures[0]) : !!existing);
1583
+ updates: { keys: [key], changeSpecs: [modifications] },
1584
+ })
1585
+ .then((res) => res.numFailures ? DexiePromise.reject(res.failures[0]) : !!existing);
1488
1586
  });
1489
1587
  });
1490
1588
  }
@@ -1492,11 +1590,11 @@ class Table {
1492
1590
  if (typeof keyOrObject === 'object' && !isArray(keyOrObject)) {
1493
1591
  const key = getByKeyPath(keyOrObject, this.schema.primKey.keyPath);
1494
1592
  if (key === undefined)
1495
- return rejection(new exceptions.InvalidArgument("Given object does not contain its primary key"));
1496
- return this.where(":id").equals(key).modify(modifications);
1593
+ return rejection(new exceptions.InvalidArgument('Given object does not contain its primary key'));
1594
+ return this.where(':id').equals(key).modify(modifications);
1497
1595
  }
1498
1596
  else {
1499
- return this.where(":id").equals(keyOrObject).modify(modifications);
1597
+ return this.where(':id').equals(keyOrObject).modify(modifications);
1500
1598
  }
1501
1599
  }
1502
1600
  put(obj, key) {
@@ -1505,9 +1603,14 @@ class Table {
1505
1603
  if (keyPath && auto) {
1506
1604
  objToAdd = workaroundForUndefinedPrimKey(keyPath)(obj);
1507
1605
  }
1508
- return this._trans('readwrite', trans => this.core.mutate({ trans, type: 'put', values: [objToAdd], keys: key != null ? [key] : null }))
1509
- .then(res => res.numFailures ? DexiePromise.reject(res.failures[0]) : res.lastResult)
1510
- .then(lastResult => {
1606
+ return this._trans('readwrite', (trans) => this.core.mutate({
1607
+ trans,
1608
+ type: 'put',
1609
+ values: [objToAdd],
1610
+ keys: key != null ? [key] : null,
1611
+ }))
1612
+ .then((res) => res.numFailures ? DexiePromise.reject(res.failures[0]) : res.lastResult)
1613
+ .then((lastResult) => {
1511
1614
  if (keyPath) {
1512
1615
  try {
1513
1616
  setByKeyPath(obj, keyPath, lastResult);
@@ -1518,38 +1621,49 @@ class Table {
1518
1621
  });
1519
1622
  }
1520
1623
  delete(key) {
1521
- return this._trans('readwrite', trans => this.core.mutate({ trans, type: 'delete', keys: [key] })
1522
- .then(res => builtInDeletionTrigger(this, [key], res))
1523
- .then(res => res.numFailures ? DexiePromise.reject(res.failures[0]) : undefined));
1624
+ return this._trans('readwrite', (trans) => this.core
1625
+ .mutate({ trans, type: 'delete', keys: [key] })
1626
+ .then((res) => builtInDeletionTrigger(this, [key], res))
1627
+ .then((res) => res.numFailures ? DexiePromise.reject(res.failures[0]) : undefined));
1524
1628
  }
1525
1629
  clear() {
1526
- return this._trans('readwrite', trans => this.core.mutate({ trans, type: 'deleteRange', range: AnyRange })
1527
- .then(res => builtInDeletionTrigger(this, null, res)))
1528
- .then(res => res.numFailures ? DexiePromise.reject(res.failures[0]) : undefined);
1630
+ return this._trans('readwrite', (trans) => this.core
1631
+ .mutate({ trans, type: 'deleteRange', range: AnyRange })
1632
+ .then((res) => builtInDeletionTrigger(this, null, res))).then((res) => res.numFailures ? DexiePromise.reject(res.failures[0]) : undefined);
1529
1633
  }
1530
1634
  bulkGet(keys) {
1531
- return this._trans('readonly', trans => {
1532
- return this.core.getMany({
1635
+ return this._trans('readonly', (trans) => {
1636
+ return this.core
1637
+ .getMany({
1533
1638
  keys,
1534
- trans
1535
- }).then(result => result.map(res => this.hook.reading.fire(res)));
1639
+ trans,
1640
+ })
1641
+ .then((result) => result.map((res) => this.hook.reading.fire(res)));
1536
1642
  });
1537
1643
  }
1538
1644
  bulkAdd(objects, keysOrOptions, options) {
1539
1645
  const keys = Array.isArray(keysOrOptions) ? keysOrOptions : undefined;
1540
- options = options || (keys ? undefined : keysOrOptions);
1646
+ options =
1647
+ options || (keys ? undefined : keysOrOptions);
1541
1648
  const wantResults = options ? options.allKeys : undefined;
1542
- return this._trans('readwrite', trans => {
1649
+ return this._trans('readwrite', (trans) => {
1543
1650
  const { auto, keyPath } = this.schema.primKey;
1544
1651
  if (keyPath && keys)
1545
- throw new exceptions.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");
1652
+ throw new exceptions.InvalidArgument('bulkAdd(): keys argument invalid on tables with inbound keys');
1546
1653
  if (keys && keys.length !== objects.length)
1547
- throw new exceptions.InvalidArgument("Arguments objects and keys must have the same length");
1654
+ throw new exceptions.InvalidArgument('Arguments objects and keys must have the same length');
1548
1655
  const numObjects = objects.length;
1549
- let objectsToAdd = keyPath && auto ?
1550
- objects.map(workaroundForUndefinedPrimKey(keyPath)) :
1551
- objects;
1552
- return this.core.mutate({ trans, type: 'add', keys: keys, values: objectsToAdd, wantResults })
1656
+ let objectsToAdd = keyPath && auto
1657
+ ? objects.map(workaroundForUndefinedPrimKey(keyPath))
1658
+ : objects;
1659
+ return this.core
1660
+ .mutate({
1661
+ trans,
1662
+ type: 'add',
1663
+ keys: keys,
1664
+ values: objectsToAdd,
1665
+ wantResults,
1666
+ })
1553
1667
  .then(({ numFailures, results, lastResult, failures }) => {
1554
1668
  const result = wantResults ? results : lastResult;
1555
1669
  if (numFailures === 0)
@@ -1560,19 +1674,27 @@ class Table {
1560
1674
  }
1561
1675
  bulkPut(objects, keysOrOptions, options) {
1562
1676
  const keys = Array.isArray(keysOrOptions) ? keysOrOptions : undefined;
1563
- options = options || (keys ? undefined : keysOrOptions);
1677
+ options =
1678
+ options || (keys ? undefined : keysOrOptions);
1564
1679
  const wantResults = options ? options.allKeys : undefined;
1565
- return this._trans('readwrite', trans => {
1680
+ return this._trans('readwrite', (trans) => {
1566
1681
  const { auto, keyPath } = this.schema.primKey;
1567
1682
  if (keyPath && keys)
1568
- throw new exceptions.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");
1683
+ throw new exceptions.InvalidArgument('bulkPut(): keys argument invalid on tables with inbound keys');
1569
1684
  if (keys && keys.length !== objects.length)
1570
- throw new exceptions.InvalidArgument("Arguments objects and keys must have the same length");
1685
+ throw new exceptions.InvalidArgument('Arguments objects and keys must have the same length');
1571
1686
  const numObjects = objects.length;
1572
- let objectsToPut = keyPath && auto ?
1573
- objects.map(workaroundForUndefinedPrimKey(keyPath)) :
1574
- objects;
1575
- return this.core.mutate({ trans, type: 'put', keys: keys, values: objectsToPut, wantResults })
1687
+ let objectsToPut = keyPath && auto
1688
+ ? objects.map(workaroundForUndefinedPrimKey(keyPath))
1689
+ : objects;
1690
+ return this.core
1691
+ .mutate({
1692
+ trans,
1693
+ type: 'put',
1694
+ keys: keys,
1695
+ values: objectsToPut,
1696
+ wantResults,
1697
+ })
1576
1698
  .then(({ numFailures, results, lastResult, failures }) => {
1577
1699
  const result = wantResults ? results : lastResult;
1578
1700
  if (numFailures === 0)
@@ -1618,8 +1740,8 @@ class Table {
1618
1740
  values: resultObjs,
1619
1741
  updates: {
1620
1742
  keys,
1621
- changeSpecs
1622
- }
1743
+ changeSpecs,
1744
+ },
1623
1745
  })
1624
1746
  .then(({ numFailures, failures }) => {
1625
1747
  if (numFailures === 0)
@@ -1639,9 +1761,10 @@ class Table {
1639
1761
  }
1640
1762
  bulkDelete(keys) {
1641
1763
  const numKeys = keys.length;
1642
- return this._trans('readwrite', trans => {
1643
- return this.core.mutate({ trans, type: 'delete', keys: keys })
1644
- .then(res => builtInDeletionTrigger(this, keys, res));
1764
+ return this._trans('readwrite', (trans) => {
1765
+ return this.core
1766
+ .mutate({ trans, type: 'delete', keys: keys })
1767
+ .then((res) => builtInDeletionTrigger(this, keys, res));
1645
1768
  }).then(({ numFailures, lastResult, failures }) => {
1646
1769
  if (numFailures === 0)
1647
1770
  return lastResult;
@@ -1660,7 +1783,7 @@ function Events(ctx) {
1660
1783
  evs[eventName].subscribe.apply(null, args);
1661
1784
  return ctx;
1662
1785
  }
1663
- else if (typeof (eventName) === 'string') {
1786
+ else if (typeof eventName === 'string') {
1664
1787
  return evs[eventName];
1665
1788
  }
1666
1789
  };
@@ -1686,9 +1809,11 @@ function Events(ctx) {
1686
1809
  }
1687
1810
  },
1688
1811
  unsubscribe: function (cb) {
1689
- context.subscribers = context.subscribers.filter(function (fn) { return fn !== cb; });
1812
+ context.subscribers = context.subscribers.filter(function (fn) {
1813
+ return fn !== cb;
1814
+ });
1690
1815
  context.fire = context.subscribers.reduce(chainFunction, defaultFunction);
1691
- }
1816
+ },
1692
1817
  };
1693
1818
  evs[eventName] = rv[eventName] = context;
1694
1819
  return context;
@@ -1712,7 +1837,7 @@ function Events(ctx) {
1712
1837
  });
1713
1838
  }
1714
1839
  else
1715
- throw new exceptions.InvalidArgument("Invalid event config");
1840
+ throw new exceptions.InvalidArgument('Invalid event config');
1716
1841
  });
1717
1842
  }
1718
1843
  }
@@ -1728,18 +1853,20 @@ function createTableConstructor(db) {
1728
1853
  this._tx = trans;
1729
1854
  this.name = name;
1730
1855
  this.schema = tableSchema;
1731
- this.hook = db._allTables[name] ? db._allTables[name].hook : Events(null, {
1732
- "creating": [hookCreatingChain, nop],
1733
- "reading": [pureFunctionChain, mirror],
1734
- "updating": [hookUpdatingChain, nop],
1735
- "deleting": [hookDeletingChain, nop]
1736
- });
1856
+ this.hook = db._allTables[name]
1857
+ ? db._allTables[name].hook
1858
+ : Events(null, {
1859
+ creating: [hookCreatingChain, nop],
1860
+ reading: [pureFunctionChain, mirror],
1861
+ updating: [hookUpdatingChain, nop],
1862
+ deleting: [hookDeletingChain, nop],
1863
+ });
1737
1864
  });
1738
1865
  }
1739
1866
 
1740
1867
  function isPlainKeyRange(ctx, ignoreLimitFilter) {
1741
- return !(ctx.filter || ctx.algorithm || ctx.or) &&
1742
- (ignoreLimitFilter ? ctx.justLimit : !ctx.replayFilter);
1868
+ return (!(ctx.filter || ctx.algorithm || ctx.or) &&
1869
+ (ignoreLimitFilter ? ctx.justLimit : !ctx.replayFilter));
1743
1870
  }
1744
1871
  function addFilter(ctx, fn) {
1745
1872
  ctx.filter = combine(ctx.filter, fn);
@@ -1757,7 +1884,11 @@ function getIndexOrStore(ctx, coreSchema) {
1757
1884
  return coreSchema.primaryKey;
1758
1885
  const index = coreSchema.getIndexByKeyPath(ctx.index);
1759
1886
  if (!index)
1760
- throw new exceptions.Schema("KeyPath " + ctx.index + " on object store " + coreSchema.name + " is not indexed");
1887
+ throw new exceptions.Schema('KeyPath ' +
1888
+ ctx.index +
1889
+ ' on object store ' +
1890
+ coreSchema.name +
1891
+ ' is not indexed');
1761
1892
  return index;
1762
1893
  }
1763
1894
  function openCursor(ctx, coreTable, trans) {
@@ -1769,19 +1900,22 @@ function openCursor(ctx, coreTable, trans) {
1769
1900
  unique: !!ctx.unique,
1770
1901
  query: {
1771
1902
  index,
1772
- range: ctx.range
1773
- }
1903
+ range: ctx.range,
1904
+ },
1774
1905
  });
1775
1906
  }
1776
1907
  function iter(ctx, fn, coreTrans, coreTable) {
1777
- const filter = ctx.replayFilter ? combine(ctx.filter, ctx.replayFilter()) : ctx.filter;
1908
+ const filter = ctx.replayFilter
1909
+ ? combine(ctx.filter, ctx.replayFilter())
1910
+ : ctx.filter;
1778
1911
  if (!ctx.or) {
1779
1912
  return iterate(openCursor(ctx, coreTable, coreTrans), combine(ctx.algorithm, filter), fn, !ctx.keysOnly && ctx.valueMapper);
1780
1913
  }
1781
1914
  else {
1782
1915
  const set = {};
1783
1916
  const union = (item, cursor, advance) => {
1784
- if (!filter || filter(cursor, advance, result => cursor.stop(result), err => cursor.fail(err))) {
1917
+ if (!filter ||
1918
+ filter(cursor, advance, (result) => cursor.stop(result), (err) => cursor.fail(err))) {
1785
1919
  var primaryKey = cursor.primaryKey;
1786
1920
  var key = '' + primaryKey;
1787
1921
  if (key === '[object ArrayBuffer]')
@@ -1794,19 +1928,26 @@ function iter(ctx, fn, coreTrans, coreTable) {
1794
1928
  };
1795
1929
  return Promise.all([
1796
1930
  ctx.or._iterate(union, coreTrans),
1797
- iterate(openCursor(ctx, coreTable, coreTrans), ctx.algorithm, union, !ctx.keysOnly && ctx.valueMapper)
1931
+ iterate(openCursor(ctx, coreTable, coreTrans), ctx.algorithm, union, !ctx.keysOnly && ctx.valueMapper),
1798
1932
  ]);
1799
1933
  }
1800
1934
  }
1801
1935
  function iterate(cursorPromise, filter, fn, valueMapper) {
1802
1936
  var mappedFn = valueMapper ? (x, c, a) => fn(valueMapper(x), c, a) : fn;
1803
1937
  var wrappedFn = wrap(mappedFn);
1804
- return cursorPromise.then(cursor => {
1938
+ return cursorPromise.then((cursor) => {
1805
1939
  if (cursor) {
1806
1940
  return cursor.start(() => {
1807
1941
  var c = () => cursor.continue();
1808
- if (!filter || filter(cursor, advancer => c = advancer, val => { cursor.stop(val); c = nop; }, e => { cursor.fail(e); c = nop; }))
1809
- wrappedFn(cursor.value, cursor, advancer => c = advancer);
1942
+ if (!filter ||
1943
+ filter(cursor, (advancer) => (c = advancer), (val) => {
1944
+ cursor.stop(val);
1945
+ c = nop;
1946
+ }, (e) => {
1947
+ cursor.fail(e);
1948
+ c = nop;
1949
+ }))
1950
+ wrappedFn(cursor.value, cursor, (advancer) => (c = advancer));
1810
1951
  c();
1811
1952
  });
1812
1953
  }
@@ -1816,15 +1957,15 @@ function iterate(cursorPromise, filter, fn, valueMapper) {
1816
1957
  class Collection {
1817
1958
  _read(fn, cb) {
1818
1959
  var ctx = this._ctx;
1819
- return ctx.error ?
1820
- ctx.table._trans(null, rejection.bind(null, ctx.error)) :
1821
- ctx.table._trans('readonly', fn).then(cb);
1960
+ return ctx.error
1961
+ ? ctx.table._trans(null, rejection.bind(null, ctx.error))
1962
+ : ctx.table._trans('readonly', fn).then(cb);
1822
1963
  }
1823
1964
  _write(fn) {
1824
1965
  var ctx = this._ctx;
1825
- return ctx.error ?
1826
- ctx.table._trans(null, rejection.bind(null, ctx.error)) :
1827
- ctx.table._trans('readwrite', fn, "locked");
1966
+ return ctx.error
1967
+ ? ctx.table._trans(null, rejection.bind(null, ctx.error))
1968
+ : ctx.table._trans('readwrite', fn, 'locked');
1828
1969
  }
1829
1970
  _addAlgorithm(fn) {
1830
1971
  var ctx = this._ctx;
@@ -1846,25 +1987,29 @@ class Collection {
1846
1987
  }
1847
1988
  each(fn) {
1848
1989
  var ctx = this._ctx;
1849
- return this._read(trans => iter(ctx, fn, trans, ctx.table.core));
1990
+ return this._read((trans) => iter(ctx, fn, trans, ctx.table.core));
1850
1991
  }
1851
1992
  count(cb) {
1852
- return this._read(trans => {
1993
+ return this._read((trans) => {
1853
1994
  const ctx = this._ctx;
1854
1995
  const coreTable = ctx.table.core;
1855
1996
  if (isPlainKeyRange(ctx, true)) {
1856
- return coreTable.count({
1997
+ return coreTable
1998
+ .count({
1857
1999
  trans,
1858
2000
  query: {
1859
2001
  index: getIndexOrStore(ctx, coreTable.schema),
1860
- range: ctx.range
1861
- }
1862
- }).then(count => Math.min(count, ctx.limit));
2002
+ range: ctx.range,
2003
+ },
2004
+ })
2005
+ .then((count) => Math.min(count, ctx.limit));
1863
2006
  }
1864
2007
  else {
1865
2008
  var count = 0;
1866
- return iter(ctx, () => { ++count; return false; }, trans, coreTable)
1867
- .then(() => count);
2009
+ return iter(ctx, () => {
2010
+ ++count;
2011
+ return false;
2012
+ }, trans, coreTable).then(() => count);
1868
2013
  }
1869
2014
  }).then(cb);
1870
2015
  }
@@ -1875,7 +2020,7 @@ class Collection {
1875
2020
  return getval(obj[parts[i]], i - 1);
1876
2021
  return obj[lastPart];
1877
2022
  }
1878
- var order = this._ctx.dir === "next" ? 1 : -1;
2023
+ var order = this._ctx.dir === 'next' ? 1 : -1;
1879
2024
  function sorter(a, b) {
1880
2025
  var aVal = getval(a, lastIndex), bVal = getval(b, lastIndex);
1881
2026
  return cmp(aVal, bVal) * order;
@@ -1885,25 +2030,27 @@ class Collection {
1885
2030
  }).then(cb);
1886
2031
  }
1887
2032
  toArray(cb) {
1888
- return this._read(trans => {
2033
+ return this._read((trans) => {
1889
2034
  var ctx = this._ctx;
1890
2035
  if (isPlainKeyRange(ctx, true) && ctx.limit > 0) {
1891
2036
  const { valueMapper } = ctx;
1892
2037
  const index = getIndexOrStore(ctx, ctx.table.core.schema);
1893
- return ctx.table.core.query({
2038
+ return ctx.table.core
2039
+ .query({
1894
2040
  trans,
1895
2041
  limit: ctx.limit,
1896
2042
  values: true,
1897
2043
  direction: ctx.dir === 'prev' ? 'prev' : undefined,
1898
2044
  query: {
1899
2045
  index,
1900
- range: ctx.range
1901
- }
1902
- }).then(({ result }) => valueMapper ? result.map(valueMapper) : result);
2046
+ range: ctx.range,
2047
+ },
2048
+ })
2049
+ .then(({ result }) => valueMapper ? result.map(valueMapper) : result);
1903
2050
  }
1904
2051
  else {
1905
2052
  const a = [];
1906
- return iter(ctx, item => a.push(item), trans, ctx.table.core).then(() => a);
2053
+ return iter(ctx, (item) => a.push(item), trans, ctx.table.core).then(() => a);
1907
2054
  }
1908
2055
  }, cb);
1909
2056
  }
@@ -1933,7 +2080,7 @@ class Collection {
1933
2080
  else {
1934
2081
  addReplayFilter(ctx, () => {
1935
2082
  var offsetLeft = offset;
1936
- return () => (--offsetLeft < 0);
2083
+ return () => --offsetLeft < 0;
1937
2084
  });
1938
2085
  }
1939
2086
  return this;
@@ -1963,7 +2110,11 @@ class Collection {
1963
2110
  return this;
1964
2111
  }
1965
2112
  first(cb) {
1966
- return this.limit(1).toArray(function (a) { return a[0]; }).then(cb);
2113
+ return this.limit(1)
2114
+ .toArray(function (a) {
2115
+ return a[0];
2116
+ })
2117
+ .then(cb);
1967
2118
  }
1968
2119
  last(cb) {
1969
2120
  return this.reverse().first(cb);
@@ -1982,7 +2133,7 @@ class Collection {
1982
2133
  return new this.db.WhereClause(this._ctx.table, indexName, this);
1983
2134
  }
1984
2135
  reverse() {
1985
- this._ctx.dir = (this._ctx.dir === "prev" ? "next" : "prev");
2136
+ this._ctx.dir = this._ctx.dir === 'prev' ? 'next' : 'prev';
1986
2137
  if (this._ondirectionchange)
1987
2138
  this._ondirectionchange(this._ctx.dir);
1988
2139
  return this;
@@ -1993,16 +2144,20 @@ class Collection {
1993
2144
  eachKey(cb) {
1994
2145
  var ctx = this._ctx;
1995
2146
  ctx.keysOnly = !ctx.isMatch;
1996
- return this.each(function (val, cursor) { cb(cursor.key, cursor); });
2147
+ return this.each(function (val, cursor) {
2148
+ cb(cursor.key, cursor);
2149
+ });
1997
2150
  }
1998
2151
  eachUniqueKey(cb) {
1999
- this._ctx.unique = "unique";
2152
+ this._ctx.unique = 'unique';
2000
2153
  return this.eachKey(cb);
2001
2154
  }
2002
2155
  eachPrimaryKey(cb) {
2003
2156
  var ctx = this._ctx;
2004
2157
  ctx.keysOnly = !ctx.isMatch;
2005
- return this.each(function (val, cursor) { cb(cursor.primaryKey, cursor); });
2158
+ return this.each(function (val, cursor) {
2159
+ cb(cursor.primaryKey, cursor);
2160
+ });
2006
2161
  }
2007
2162
  keys(cb) {
2008
2163
  var ctx = this._ctx;
@@ -2010,14 +2165,16 @@ class Collection {
2010
2165
  var a = [];
2011
2166
  return this.each(function (item, cursor) {
2012
2167
  a.push(cursor.key);
2013
- }).then(function () {
2168
+ })
2169
+ .then(function () {
2014
2170
  return a;
2015
- }).then(cb);
2171
+ })
2172
+ .then(cb);
2016
2173
  }
2017
2174
  primaryKeys(cb) {
2018
2175
  var ctx = this._ctx;
2019
2176
  if (isPlainKeyRange(ctx, true) && ctx.limit > 0) {
2020
- return this._read(trans => {
2177
+ return this._read((trans) => {
2021
2178
  var index = getIndexOrStore(ctx, ctx.table.core.schema);
2022
2179
  return ctx.table.core.query({
2023
2180
  trans,
@@ -2026,25 +2183,33 @@ class Collection {
2026
2183
  direction: ctx.dir === 'prev' ? 'prev' : undefined,
2027
2184
  query: {
2028
2185
  index,
2029
- range: ctx.range
2030
- }
2186
+ range: ctx.range,
2187
+ },
2031
2188
  });
2032
- }).then(({ result }) => result).then(cb);
2189
+ })
2190
+ .then(({ result }) => result)
2191
+ .then(cb);
2033
2192
  }
2034
2193
  ctx.keysOnly = !ctx.isMatch;
2035
2194
  var a = [];
2036
2195
  return this.each(function (item, cursor) {
2037
2196
  a.push(cursor.primaryKey);
2038
- }).then(function () {
2197
+ })
2198
+ .then(function () {
2039
2199
  return a;
2040
- }).then(cb);
2200
+ })
2201
+ .then(cb);
2041
2202
  }
2042
2203
  uniqueKeys(cb) {
2043
- this._ctx.unique = "unique";
2204
+ this._ctx.unique = 'unique';
2044
2205
  return this.keys(cb);
2045
2206
  }
2046
2207
  firstKey(cb) {
2047
- return this.limit(1).keys(function (a) { return a[0]; }).then(cb);
2208
+ return this.limit(1)
2209
+ .keys(function (a) {
2210
+ return a[0];
2211
+ })
2212
+ .then(cb);
2048
2213
  }
2049
2214
  lastKey(cb) {
2050
2215
  return this.reverse().firstKey(cb);
@@ -2064,13 +2229,13 @@ class Collection {
2064
2229
  }
2065
2230
  modify(changes) {
2066
2231
  var ctx = this._ctx;
2067
- return this._write(trans => {
2232
+ return this._write((trans) => {
2068
2233
  var modifyer;
2069
2234
  if (typeof changes === 'function') {
2070
2235
  modifyer = changes;
2071
2236
  }
2072
2237
  else {
2073
- modifyer = item => applyUpdateSpec(item, changes);
2238
+ modifyer = (item) => applyUpdateSpec(item, changes);
2074
2239
  }
2075
2240
  const coreTable = ctx.table.core;
2076
2241
  const { outbound, extractKey } = coreTable.schema.primaryKey;
@@ -2078,7 +2243,8 @@ class Collection {
2078
2243
  const modifyChunkSize = this.db._options.modifyChunkSize;
2079
2244
  if (modifyChunkSize) {
2080
2245
  if (typeof modifyChunkSize == 'object') {
2081
- limit = modifyChunkSize[coreTable.name] || modifyChunkSize['*'] || 200;
2246
+ limit =
2247
+ modifyChunkSize[coreTable.name] || modifyChunkSize['*'] || 200;
2082
2248
  }
2083
2249
  else {
2084
2250
  limit = modifyChunkSize;
@@ -2095,21 +2261,25 @@ class Collection {
2095
2261
  }
2096
2262
  };
2097
2263
  const isUnconditionalDelete = changes === deleteCallback;
2098
- return this.clone().primaryKeys().then(keys => {
2264
+ return this.clone()
2265
+ .primaryKeys()
2266
+ .then((keys) => {
2099
2267
  const criteria = isPlainKeyRange(ctx) &&
2100
2268
  ctx.limit === Infinity &&
2101
2269
  (typeof changes !== 'function' || isUnconditionalDelete) && {
2102
2270
  index: ctx.index,
2103
- range: ctx.range
2271
+ range: ctx.range,
2104
2272
  };
2105
2273
  const nextChunk = (offset) => {
2106
2274
  const count = Math.min(limit, keys.length - offset);
2107
2275
  const keysInChunk = keys.slice(offset, offset + count);
2108
- return (isUnconditionalDelete ? Promise.resolve([]) : coreTable.getMany({
2109
- trans,
2110
- keys: keysInChunk,
2111
- cache: "immutable"
2112
- })).then(values => {
2276
+ return (isUnconditionalDelete
2277
+ ? Promise.resolve([])
2278
+ : coreTable.getMany({
2279
+ trans,
2280
+ keys: keysInChunk,
2281
+ cache: 'immutable',
2282
+ })).then((values) => {
2113
2283
  const addValues = [];
2114
2284
  const putValues = [];
2115
2285
  const putKeys = outbound ? [] : null;
@@ -2119,13 +2289,14 @@ class Collection {
2119
2289
  const origValue = values[i];
2120
2290
  const ctx = {
2121
2291
  value: deepClone(origValue),
2122
- primKey: keys[offset + i]
2292
+ primKey: keys[offset + i],
2123
2293
  };
2124
2294
  if (modifyer.call(ctx, ctx.value, ctx) !== false) {
2125
2295
  if (ctx.value == null) {
2126
2296
  deleteKeys.push(keys[offset + i]);
2127
2297
  }
2128
- else if (!outbound && cmp(extractKey(origValue), extractKey(ctx.value)) !== 0) {
2298
+ else if (!outbound &&
2299
+ cmp(extractKey(origValue), extractKey(ctx.value)) !== 0) {
2129
2300
  deleteKeys.push(keys[offset + i]);
2130
2301
  addValues.push(ctx.value);
2131
2302
  }
@@ -2137,38 +2308,47 @@ class Collection {
2137
2308
  }
2138
2309
  }
2139
2310
  return Promise.resolve(addValues.length > 0 &&
2140
- coreTable.mutate({ trans, type: 'add', values: addValues })
2141
- .then(res => {
2311
+ coreTable
2312
+ .mutate({ trans, type: 'add', values: addValues })
2313
+ .then((res) => {
2142
2314
  for (let pos in res.failures) {
2143
2315
  deleteKeys.splice(parseInt(pos), 1);
2144
2316
  }
2145
2317
  applyMutateResult(addValues.length, res);
2146
- })).then(() => (putValues.length > 0 || (criteria && typeof changes === 'object')) &&
2147
- coreTable.mutate({
2318
+ }))
2319
+ .then(() => (putValues.length > 0 ||
2320
+ (criteria && typeof changes === 'object')) &&
2321
+ coreTable
2322
+ .mutate({
2148
2323
  trans,
2149
2324
  type: 'put',
2150
2325
  keys: putKeys,
2151
2326
  values: putValues,
2152
2327
  criteria,
2153
- changeSpec: typeof changes !== 'function'
2154
- && changes,
2155
- isAdditionalChunk: offset > 0
2156
- }).then(res => applyMutateResult(putValues.length, res))).then(() => (deleteKeys.length > 0 || (criteria && isUnconditionalDelete)) &&
2157
- coreTable.mutate({
2328
+ changeSpec: typeof changes !== 'function' && changes,
2329
+ isAdditionalChunk: offset > 0,
2330
+ })
2331
+ .then((res) => applyMutateResult(putValues.length, res)))
2332
+ .then(() => (deleteKeys.length > 0 ||
2333
+ (criteria && isUnconditionalDelete)) &&
2334
+ coreTable
2335
+ .mutate({
2158
2336
  trans,
2159
2337
  type: 'delete',
2160
2338
  keys: deleteKeys,
2161
2339
  criteria,
2162
- isAdditionalChunk: offset > 0
2163
- }).then(res => builtInDeletionTrigger(ctx.table, deleteKeys, res))
2164
- .then(res => applyMutateResult(deleteKeys.length, res))).then(() => {
2165
- return keys.length > offset + count && nextChunk(offset + limit);
2340
+ isAdditionalChunk: offset > 0,
2341
+ })
2342
+ .then((res) => builtInDeletionTrigger(ctx.table, deleteKeys, res))
2343
+ .then((res) => applyMutateResult(deleteKeys.length, res)))
2344
+ .then(() => {
2345
+ return (keys.length > offset + count && nextChunk(offset + limit));
2166
2346
  });
2167
2347
  });
2168
2348
  };
2169
2349
  return nextChunk(0).then(() => {
2170
2350
  if (totalFailures.length > 0)
2171
- throw new ModifyError("Error modifying one or more objects", totalFailures, successCount, failedKeys);
2351
+ throw new ModifyError('Error modifying one or more objects', totalFailures, successCount, failedKeys);
2172
2352
  return keys.length;
2173
2353
  });
2174
2354
  });
@@ -2180,14 +2360,17 @@ class Collection {
2180
2360
  !ctx.table.schema.yProps &&
2181
2361
  (ctx.isPrimKey || range.type === 3 ))
2182
2362
  {
2183
- return this._write(trans => {
2363
+ return this._write((trans) => {
2184
2364
  const { primaryKey } = ctx.table.core.schema;
2185
2365
  const coreRange = range;
2186
- return ctx.table.core.count({ trans, query: { index: primaryKey, range: coreRange } }).then(count => {
2187
- return ctx.table.core.mutate({ trans, type: 'deleteRange', range: coreRange })
2366
+ return ctx.table.core
2367
+ .count({ trans, query: { index: primaryKey, range: coreRange } })
2368
+ .then((count) => {
2369
+ return ctx.table.core
2370
+ .mutate({ trans, type: 'deleteRange', range: coreRange })
2188
2371
  .then(({ failures, numFailures }) => {
2189
2372
  if (numFailures)
2190
- throw new ModifyError("Could not delete some values", Object.keys(failures).map(pos => failures[pos]), count - numFailures);
2373
+ throw new ModifyError('Could not delete some values', Object.keys(failures).map((pos) => failures[pos]), count - numFailures);
2191
2374
  return count - numFailures;
2192
2375
  });
2193
2376
  });
@@ -2196,7 +2379,7 @@ class Collection {
2196
2379
  return this.modify(deleteCallback);
2197
2380
  }
2198
2381
  }
2199
- const deleteCallback = (value, ctx) => ctx.value = null;
2382
+ const deleteCallback = (value, ctx) => (ctx.value = null);
2200
2383
 
2201
2384
  function createCollectionConstructor(db) {
2202
2385
  return makeClassConstructor(Collection.prototype, function Collection(whereClause, keyRangeGenerator) {
@@ -2215,11 +2398,13 @@ function createCollectionConstructor(db) {
2215
2398
  this._ctx = {
2216
2399
  table: table,
2217
2400
  index: whereCtx.index,
2218
- isPrimKey: (!whereCtx.index || (table.schema.primKey.keyPath && whereCtx.index === table.schema.primKey.name)),
2401
+ isPrimKey: !whereCtx.index ||
2402
+ (table.schema.primKey.keyPath &&
2403
+ whereCtx.index === table.schema.primKey.name),
2219
2404
  range: keyRange,
2220
2405
  keysOnly: false,
2221
- dir: "next",
2222
- unique: "",
2406
+ dir: 'next',
2407
+ unique: '',
2223
2408
  algorithm: null,
2224
2409
  filter: null,
2225
2410
  replayFilter: null,
@@ -2229,7 +2414,7 @@ function createCollectionConstructor(db) {
2229
2414
  limit: Infinity,
2230
2415
  error: error,
2231
2416
  or: whereCtx.or,
2232
- valueMapper: readingHook !== mirror ? readingHook : null
2417
+ valueMapper: readingHook !== mirror ? readingHook : null,
2233
2418
  };
2234
2419
  });
2235
2420
  }
@@ -2242,24 +2427,24 @@ function simpleCompareReverse(a, b) {
2242
2427
  }
2243
2428
 
2244
2429
  function fail(collectionOrWhereClause, err, T) {
2245
- var collection = collectionOrWhereClause instanceof WhereClause ?
2246
- new collectionOrWhereClause.Collection(collectionOrWhereClause) :
2247
- collectionOrWhereClause;
2430
+ var collection = collectionOrWhereClause instanceof WhereClause
2431
+ ? new collectionOrWhereClause.Collection(collectionOrWhereClause)
2432
+ : collectionOrWhereClause;
2248
2433
  collection._ctx.error = T ? new T(err) : new TypeError(err);
2249
2434
  return collection;
2250
2435
  }
2251
2436
  function emptyCollection(whereClause) {
2252
- return new whereClause.Collection(whereClause, () => rangeEqual("")).limit(0);
2437
+ return new whereClause.Collection(whereClause, () => rangeEqual('')).limit(0);
2253
2438
  }
2254
2439
  function upperFactory(dir) {
2255
- return dir === "next" ?
2256
- (s) => s.toUpperCase() :
2257
- (s) => s.toLowerCase();
2440
+ return dir === 'next'
2441
+ ? (s) => s.toUpperCase()
2442
+ : (s) => s.toLowerCase();
2258
2443
  }
2259
2444
  function lowerFactory(dir) {
2260
- return dir === "next" ?
2261
- (s) => s.toLowerCase() :
2262
- (s) => s.toUpperCase();
2445
+ return dir === 'next'
2446
+ ? (s) => s.toLowerCase()
2447
+ : (s) => s.toUpperCase();
2263
2448
  }
2264
2449
  function nextCasing(key, lowerKey, upperNeedle, lowerNeedle, cmp, dir) {
2265
2450
  var length = Math.min(key.length, lowerNeedle.length);
@@ -2278,32 +2463,40 @@ function nextCasing(key, lowerKey, upperNeedle, lowerNeedle, cmp, dir) {
2278
2463
  if (cmp(key[i], lwrKeyChar) < 0)
2279
2464
  llp = i;
2280
2465
  }
2281
- if (length < lowerNeedle.length && dir === "next")
2466
+ if (length < lowerNeedle.length && dir === 'next')
2282
2467
  return key + upperNeedle.substr(key.length);
2283
- if (length < key.length && dir === "prev")
2468
+ if (length < key.length && dir === 'prev')
2284
2469
  return key.substr(0, upperNeedle.length);
2285
- return (llp < 0 ? null : key.substr(0, llp) + lowerNeedle[llp] + upperNeedle.substr(llp + 1));
2470
+ return llp < 0
2471
+ ? null
2472
+ : key.substr(0, llp) + lowerNeedle[llp] + upperNeedle.substr(llp + 1);
2286
2473
  }
2287
2474
  function addIgnoreCaseAlgorithm(whereClause, match, needles, suffix) {
2288
2475
  var upper, lower, compare, upperNeedles, lowerNeedles, direction, nextKeySuffix, needlesLen = needles.length;
2289
- if (!needles.every(s => typeof s === 'string')) {
2476
+ if (!needles.every((s) => typeof s === 'string')) {
2290
2477
  return fail(whereClause, STRING_EXPECTED);
2291
2478
  }
2292
2479
  function initDirection(dir) {
2293
2480
  upper = upperFactory(dir);
2294
2481
  lower = lowerFactory(dir);
2295
- compare = (dir === "next" ? simpleCompare : simpleCompareReverse);
2296
- var needleBounds = needles.map(function (needle) {
2482
+ compare = dir === 'next' ? simpleCompare : simpleCompareReverse;
2483
+ var needleBounds = needles
2484
+ .map(function (needle) {
2297
2485
  return { lower: lower(needle), upper: upper(needle) };
2298
- }).sort(function (a, b) {
2486
+ })
2487
+ .sort(function (a, b) {
2299
2488
  return compare(a.lower, b.lower);
2300
2489
  });
2301
- upperNeedles = needleBounds.map(function (nb) { return nb.upper; });
2302
- lowerNeedles = needleBounds.map(function (nb) { return nb.lower; });
2490
+ upperNeedles = needleBounds.map(function (nb) {
2491
+ return nb.upper;
2492
+ });
2493
+ lowerNeedles = needleBounds.map(function (nb) {
2494
+ return nb.lower;
2495
+ });
2303
2496
  direction = dir;
2304
- nextKeySuffix = (dir === "next" ? "" : suffix);
2497
+ nextKeySuffix = dir === 'next' ? '' : suffix;
2305
2498
  }
2306
- initDirection("next");
2499
+ initDirection('next');
2307
2500
  var c = new whereClause.Collection(whereClause, () => createRange(upperNeedles[0], lowerNeedles[needlesLen - 1] + suffix));
2308
2501
  c._ondirectionchange = function (direction) {
2309
2502
  initDirection(direction);
@@ -2323,12 +2516,15 @@ function addIgnoreCaseAlgorithm(whereClause, match, needles, suffix) {
2323
2516
  var casing = nextCasing(key, lowerKey, upperNeedles[i], lowerNeedles[i], compare, direction);
2324
2517
  if (casing === null && lowestPossibleCasing === null)
2325
2518
  firstPossibleNeedle = i + 1;
2326
- else if (lowestPossibleCasing === null || compare(lowestPossibleCasing, casing) > 0) {
2519
+ else if (lowestPossibleCasing === null ||
2520
+ compare(lowestPossibleCasing, casing) > 0) {
2327
2521
  lowestPossibleCasing = casing;
2328
2522
  }
2329
2523
  }
2330
2524
  if (lowestPossibleCasing !== null) {
2331
- advance(function () { cursor.continue(lowestPossibleCasing + nextKeySuffix); });
2525
+ advance(function () {
2526
+ cursor.continue(lowestPossibleCasing + nextKeySuffix);
2527
+ });
2332
2528
  }
2333
2529
  else {
2334
2530
  advance(resolve);
@@ -2344,14 +2540,14 @@ function createRange(lower, upper, lowerOpen, upperOpen) {
2344
2540
  lower,
2345
2541
  upper,
2346
2542
  lowerOpen,
2347
- upperOpen
2543
+ upperOpen,
2348
2544
  };
2349
2545
  }
2350
2546
  function rangeEqual(value) {
2351
2547
  return {
2352
2548
  type: 1 ,
2353
2549
  lower: value,
2354
- upper: value
2550
+ upper: value,
2355
2551
  };
2356
2552
  }
2357
2553
 
@@ -2363,8 +2559,10 @@ class WhereClause {
2363
2559
  includeLower = includeLower !== false;
2364
2560
  includeUpper = includeUpper === true;
2365
2561
  try {
2366
- if ((this._cmp(lower, upper) > 0) ||
2367
- (this._cmp(lower, upper) === 0 && (includeLower || includeUpper) && !(includeLower && includeUpper)))
2562
+ if (this._cmp(lower, upper) > 0 ||
2563
+ (this._cmp(lower, upper) === 0 &&
2564
+ (includeLower || includeUpper) &&
2565
+ !(includeLower && includeUpper)))
2368
2566
  return emptyCollection(this);
2369
2567
  return new this.Collection(this, () => createRange(lower, upper, !includeLower, !includeUpper));
2370
2568
  }
@@ -2403,24 +2601,24 @@ class WhereClause {
2403
2601
  return this.between(str, str + maxString, true, true);
2404
2602
  }
2405
2603
  startsWithIgnoreCase(str) {
2406
- if (str === "")
2604
+ if (str === '')
2407
2605
  return this.startsWith(str);
2408
2606
  return addIgnoreCaseAlgorithm(this, (x, a) => x.indexOf(a[0]) === 0, [str], maxString);
2409
2607
  }
2410
2608
  equalsIgnoreCase(str) {
2411
- return addIgnoreCaseAlgorithm(this, (x, a) => x === a[0], [str], "");
2609
+ return addIgnoreCaseAlgorithm(this, (x, a) => x === a[0], [str], '');
2412
2610
  }
2413
2611
  anyOfIgnoreCase() {
2414
2612
  var set = getArrayOf.apply(NO_CHAR_ARRAY, arguments);
2415
2613
  if (set.length === 0)
2416
2614
  return emptyCollection(this);
2417
- return addIgnoreCaseAlgorithm(this, (x, a) => a.indexOf(x) !== -1, set, "");
2615
+ return addIgnoreCaseAlgorithm(this, (x, a) => a.indexOf(x) !== -1, set, '');
2418
2616
  }
2419
2617
  startsWithAnyOfIgnoreCase() {
2420
2618
  var set = getArrayOf.apply(NO_CHAR_ARRAY, arguments);
2421
2619
  if (set.length === 0)
2422
2620
  return emptyCollection(this);
2423
- return addIgnoreCaseAlgorithm(this, (x, a) => a.some(n => x.indexOf(n) === 0), set, maxString);
2621
+ return addIgnoreCaseAlgorithm(this, (x, a) => a.some((n) => x.indexOf(n) === 0), set, maxString);
2424
2622
  }
2425
2623
  anyOf() {
2426
2624
  const set = getArrayOf.apply(NO_CHAR_ARRAY, arguments);
@@ -2434,10 +2632,8 @@ class WhereClause {
2434
2632
  if (set.length === 0)
2435
2633
  return emptyCollection(this);
2436
2634
  const c = new this.Collection(this, () => createRange(set[0], set[set.length - 1]));
2437
- c._ondirectionchange = direction => {
2438
- compare = (direction === "next" ?
2439
- this._ascending :
2440
- this._descending);
2635
+ c._ondirectionchange = (direction) => {
2636
+ compare = direction === 'next' ? this._ascending : this._descending;
2441
2637
  set.sort(compare);
2442
2638
  };
2443
2639
  let i = 0;
@@ -2454,14 +2650,19 @@ class WhereClause {
2454
2650
  return true;
2455
2651
  }
2456
2652
  else {
2457
- advance(() => { cursor.continue(set[i]); });
2653
+ advance(() => {
2654
+ cursor.continue(set[i]);
2655
+ });
2458
2656
  return false;
2459
2657
  }
2460
2658
  });
2461
2659
  return c;
2462
2660
  }
2463
2661
  notEqual(value) {
2464
- return this.inAnyRange([[minKey, value], [value, this.db._maxKey]], { includeLowers: false, includeUppers: false });
2662
+ return this.inAnyRange([
2663
+ [minKey, value],
2664
+ [value, this.db._maxKey],
2665
+ ], { includeLowers: false, includeUppers: false });
2465
2666
  }
2466
2667
  noneOf() {
2467
2668
  const set = getArrayOf.apply(NO_CHAR_ARRAY, arguments);
@@ -2473,20 +2674,21 @@ class WhereClause {
2473
2674
  catch (e) {
2474
2675
  return fail(this, INVALID_KEY_ARGUMENT);
2475
2676
  }
2476
- const ranges = set.reduce((res, val) => res ?
2477
- res.concat([[res[res.length - 1][1], val]]) :
2478
- [[minKey, val]], null);
2677
+ const ranges = set.reduce((res, val) => res ? res.concat([[res[res.length - 1][1], val]]) : [[minKey, val]], null);
2479
2678
  ranges.push([set[set.length - 1], this.db._maxKey]);
2480
- return this.inAnyRange(ranges, { includeLowers: false, includeUppers: false });
2679
+ return this.inAnyRange(ranges, {
2680
+ includeLowers: false,
2681
+ includeUppers: false,
2682
+ });
2481
2683
  }
2482
2684
  inAnyRange(ranges, options) {
2483
2685
  const cmp = this._cmp, ascending = this._ascending, descending = this._descending, min = this._min, max = this._max;
2484
2686
  if (ranges.length === 0)
2485
2687
  return emptyCollection(this);
2486
- if (!ranges.every(range => range[0] !== undefined &&
2688
+ if (!ranges.every((range) => range[0] !== undefined &&
2487
2689
  range[1] !== undefined &&
2488
2690
  ascending(range[0], range[1]) <= 0)) {
2489
- return fail(this, "First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower", exceptions.InvalidArgument);
2691
+ return fail(this, 'First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower', exceptions.InvalidArgument);
2490
2692
  }
2491
2693
  const includeLowers = !options || options.includeLowers !== false;
2492
2694
  const includeUppers = options && options.includeUppers === true;
@@ -2505,7 +2707,9 @@ class WhereClause {
2505
2707
  return ranges;
2506
2708
  }
2507
2709
  let sortDirection = ascending;
2508
- function rangeSorter(a, b) { return sortDirection(a[0], b[0]); }
2710
+ function rangeSorter(a, b) {
2711
+ return sortDirection(a[0], b[0]);
2712
+ }
2509
2713
  let set;
2510
2714
  try {
2511
2715
  set = ranges.reduce(addRange, []);
@@ -2515,19 +2719,19 @@ class WhereClause {
2515
2719
  return fail(this, INVALID_KEY_ARGUMENT);
2516
2720
  }
2517
2721
  let rangePos = 0;
2518
- const keyIsBeyondCurrentEntry = includeUppers ?
2519
- key => ascending(key, set[rangePos][1]) > 0 :
2520
- key => ascending(key, set[rangePos][1]) >= 0;
2521
- const keyIsBeforeCurrentEntry = includeLowers ?
2522
- key => descending(key, set[rangePos][0]) > 0 :
2523
- key => descending(key, set[rangePos][0]) >= 0;
2722
+ const keyIsBeyondCurrentEntry = includeUppers
2723
+ ? (key) => ascending(key, set[rangePos][1]) > 0
2724
+ : (key) => ascending(key, set[rangePos][1]) >= 0;
2725
+ const keyIsBeforeCurrentEntry = includeLowers
2726
+ ? (key) => descending(key, set[rangePos][0]) > 0
2727
+ : (key) => descending(key, set[rangePos][0]) >= 0;
2524
2728
  function keyWithinCurrentRange(key) {
2525
2729
  return !keyIsBeyondCurrentEntry(key) && !keyIsBeforeCurrentEntry(key);
2526
2730
  }
2527
2731
  let checkKey = keyIsBeyondCurrentEntry;
2528
2732
  const c = new this.Collection(this, () => createRange(set[0][0], set[set.length - 1][1], !includeLowers, !includeUppers));
2529
- c._ondirectionchange = direction => {
2530
- if (direction === "next") {
2733
+ c._ondirectionchange = (direction) => {
2734
+ if (direction === 'next') {
2531
2735
  checkKey = keyIsBeyondCurrentEntry;
2532
2736
  sortDirection = ascending;
2533
2737
  }
@@ -2549,7 +2753,8 @@ class WhereClause {
2549
2753
  if (keyWithinCurrentRange(key)) {
2550
2754
  return true;
2551
2755
  }
2552
- else if (this._cmp(key, set[rangePos][1]) === 0 || this._cmp(key, set[rangePos][0]) === 0) {
2756
+ else if (this._cmp(key, set[rangePos][1]) === 0 ||
2757
+ this._cmp(key, set[rangePos][0]) === 0) {
2553
2758
  return false;
2554
2759
  }
2555
2760
  else {
@@ -2566,8 +2771,8 @@ class WhereClause {
2566
2771
  }
2567
2772
  startsWithAnyOf() {
2568
2773
  const set = getArrayOf.apply(NO_CHAR_ARRAY, arguments);
2569
- if (!set.every(s => typeof s === 'string')) {
2570
- return fail(this, "startsWithAnyOf() only works with strings");
2774
+ if (!set.every((s) => typeof s === 'string')) {
2775
+ return fail(this, 'startsWithAnyOf() only works with strings');
2571
2776
  }
2572
2777
  if (set.length === 0)
2573
2778
  return emptyCollection(this);
@@ -2580,13 +2785,13 @@ function createWhereClauseConstructor(db) {
2580
2785
  this.db = db;
2581
2786
  this._ctx = {
2582
2787
  table: table,
2583
- index: index === ":id" ? null : index,
2584
- or: orCollection
2788
+ index: index === ':id' ? null : index,
2789
+ or: orCollection,
2585
2790
  };
2586
2791
  this._cmp = this._ascending = cmp;
2587
2792
  this._descending = (a, b) => cmp(b, a);
2588
- this._max = (a, b) => cmp(a, b) > 0 ? a : b;
2589
- this._min = (a, b) => cmp(a, b) < 0 ? a : b;
2793
+ this._max = (a, b) => (cmp(a, b) > 0 ? a : b);
2794
+ this._min = (a, b) => (cmp(a, b) < 0 ? a : b);
2590
2795
  this._IDBKeyRange = db._deps.IDBKeyRange;
2591
2796
  if (!this._IDBKeyRange)
2592
2797
  throw new exceptions.MissingAPI();
@@ -2645,9 +2850,9 @@ class Transaction {
2645
2850
  assert(!this.idbtrans);
2646
2851
  if (!idbtrans && !idbdb) {
2647
2852
  switch (dbOpenError && dbOpenError.name) {
2648
- case "DatabaseClosedError":
2853
+ case 'DatabaseClosedError':
2649
2854
  throw new exceptions.DatabaseClosed(dbOpenError);
2650
- case "MissingAPIError":
2855
+ case 'MissingAPIError':
2651
2856
  throw new exceptions.MissingAPI(dbOpenError.message, dbOpenError);
2652
2857
  default:
2653
2858
  throw new exceptions.OpenFailed(dbOpenError);
@@ -2656,39 +2861,45 @@ class Transaction {
2656
2861
  if (!this.active)
2657
2862
  throw new exceptions.TransactionInactive();
2658
2863
  assert(this._completion._state === null);
2659
- idbtrans = this.idbtrans = idbtrans ||
2660
- (this.db.core
2661
- ? this.db.core.transaction(this.storeNames, this.mode, { durability: this.chromeTransactionDurability })
2662
- : idbdb.transaction(this.storeNames, this.mode, { durability: this.chromeTransactionDurability }));
2663
- idbtrans.onerror = wrap(ev => {
2864
+ idbtrans = this.idbtrans =
2865
+ idbtrans ||
2866
+ (this.db.core
2867
+ ? this.db.core.transaction(this.storeNames, this.mode, { durability: this.chromeTransactionDurability })
2868
+ : idbdb.transaction(this.storeNames, this.mode, {
2869
+ durability: this.chromeTransactionDurability,
2870
+ }));
2871
+ idbtrans.onerror = wrap((ev) => {
2664
2872
  preventDefault(ev);
2665
2873
  this._reject(idbtrans.error);
2666
2874
  });
2667
- idbtrans.onabort = wrap(ev => {
2875
+ idbtrans.onabort = wrap((ev) => {
2668
2876
  preventDefault(ev);
2669
2877
  this.active && this._reject(new exceptions.Abort(idbtrans.error));
2670
2878
  this.active = false;
2671
- this.on("abort").fire(ev);
2879
+ this.on('abort').fire(ev);
2672
2880
  });
2673
2881
  idbtrans.oncomplete = wrap(() => {
2674
2882
  this.active = false;
2675
2883
  this._resolve();
2676
2884
  if ('mutatedParts' in idbtrans) {
2677
- globalEvents.storagemutated.fire(idbtrans["mutatedParts"]);
2885
+ globalEvents.storagemutated.fire(idbtrans['mutatedParts']);
2678
2886
  }
2679
2887
  });
2680
2888
  return this;
2681
2889
  }
2682
2890
  _promise(mode, fn, bWriteLock) {
2683
2891
  if (mode === 'readwrite' && this.mode !== 'readwrite')
2684
- return rejection(new exceptions.ReadOnly("Transaction is readonly"));
2892
+ return rejection(new exceptions.ReadOnly('Transaction is readonly'));
2685
2893
  if (!this.active)
2686
2894
  return rejection(new exceptions.TransactionInactive());
2687
2895
  if (this._locked()) {
2688
2896
  return new DexiePromise((resolve, reject) => {
2689
- this._blockedFuncs.push([() => {
2897
+ this._blockedFuncs.push([
2898
+ () => {
2690
2899
  this._promise(mode, fn, bWriteLock).then(resolve, reject);
2691
- }, PSD]);
2900
+ },
2901
+ PSD,
2902
+ ]);
2692
2903
  });
2693
2904
  }
2694
2905
  else if (bWriteLock) {
@@ -2730,14 +2941,16 @@ class Transaction {
2730
2941
  (function spin() {
2731
2942
  ++root._spinCount;
2732
2943
  while (root._waitingQueue.length)
2733
- (root._waitingQueue.shift())();
2944
+ root._waitingQueue.shift()();
2734
2945
  if (root._waitingFor)
2735
2946
  store.get(-Infinity).onsuccess = spin;
2736
- }());
2947
+ })();
2737
2948
  }
2738
2949
  var currentWaitPromise = root._waitingFor;
2739
2950
  return new DexiePromise((resolve, reject) => {
2740
- promise.then(res => root._waitingQueue.push(wrap(resolve.bind(null, res))), err => root._waitingQueue.push(wrap(reject.bind(null, err)))).finally(() => {
2951
+ promise
2952
+ .then((res) => root._waitingQueue.push(wrap(resolve.bind(null, res))), (err) => root._waitingQueue.push(wrap(reject.bind(null, err))))
2953
+ .finally(() => {
2741
2954
  if (root._waitingFor === currentWaitPromise) {
2742
2955
  root._waitingFor = null;
2743
2956
  }
@@ -2753,12 +2966,12 @@ class Transaction {
2753
2966
  }
2754
2967
  }
2755
2968
  table(tableName) {
2756
- const memoizedTables = (this._memoizedTables || (this._memoizedTables = {}));
2969
+ const memoizedTables = this._memoizedTables || (this._memoizedTables = {});
2757
2970
  if (hasOwn(memoizedTables, tableName))
2758
2971
  return memoizedTables[tableName];
2759
2972
  const tableSchema = this.schema[tableName];
2760
2973
  if (!tableSchema) {
2761
- throw new exceptions.NotFound("Table " + tableName + " not part of transaction");
2974
+ throw new exceptions.NotFound('Table ' + tableName + ' not part of transaction');
2762
2975
  }
2763
2976
  const transactionBoundTable = new this.db.Table(tableName, tableSchema, this);
2764
2977
  transactionBoundTable.core = this.db.core.table(tableName);
@@ -2770,10 +2983,10 @@ class Transaction {
2770
2983
  function createTransactionConstructor(db) {
2771
2984
  return makeClassConstructor(Transaction.prototype, function Transaction(mode, storeNames, dbschema, chromeTransactionDurability, parent) {
2772
2985
  if (mode !== 'readonly')
2773
- storeNames.forEach(storeName => {
2986
+ storeNames.forEach((storeName) => {
2774
2987
  const yProps = dbschema[storeName]?.yProps;
2775
2988
  if (yProps)
2776
- storeNames = storeNames.concat(yProps.map(p => p.updatesTable));
2989
+ storeNames = storeNames.concat(yProps.map((p) => p.updatesTable));
2777
2990
  });
2778
2991
  this.db = db;
2779
2992
  this.mode = mode;
@@ -2781,7 +2994,7 @@ function createTransactionConstructor(db) {
2781
2994
  this.schema = dbschema;
2782
2995
  this.chromeTransactionDurability = chromeTransactionDurability;
2783
2996
  this.idbtrans = null;
2784
- this.on = Events(this, "complete", "error", "abort");
2997
+ this.on = Events(this, 'complete', 'error', 'abort');
2785
2998
  this.parent = parent || null;
2786
2999
  this.active = true;
2787
3000
  this._reculock = 0;
@@ -2798,13 +3011,13 @@ function createTransactionConstructor(db) {
2798
3011
  this._completion.then(() => {
2799
3012
  this.active = false;
2800
3013
  this.on.complete.fire();
2801
- }, e => {
3014
+ }, (e) => {
2802
3015
  var wasActive = this.active;
2803
3016
  this.active = false;
2804
3017
  this.on.error.fire(e);
2805
- this.parent ?
2806
- this.parent._reject(e) :
2807
- wasActive && this.idbtrans && this.idbtrans.abort();
3018
+ this.parent
3019
+ ? this.parent._reject(e)
3020
+ : wasActive && this.idbtrans && this.idbtrans.abort();
2808
3021
  return rejection(e);
2809
3022
  });
2810
3023
  });
@@ -2818,14 +3031,19 @@ function createIndexSpec(name, keyPath, unique, multi, auto, compound, isPrimKey
2818
3031
  multi,
2819
3032
  auto,
2820
3033
  compound,
2821
- src: (unique && !isPrimKey ? '&' : '') + (multi ? '*' : '') + (auto ? "++" : "") + nameFromKeyPath(keyPath),
2822
- type
3034
+ src: (unique && !isPrimKey ? '&' : '') +
3035
+ (multi ? '*' : '') +
3036
+ (auto ? '++' : '') +
3037
+ nameFromKeyPath(keyPath),
3038
+ type,
2823
3039
  };
2824
3040
  }
2825
3041
  function nameFromKeyPath(keyPath) {
2826
- return typeof keyPath === 'string' ?
2827
- keyPath :
2828
- keyPath ? ('[' + [].join.call(keyPath, '+') + ']') : "";
3042
+ return typeof keyPath === 'string'
3043
+ ? keyPath
3044
+ : keyPath
3045
+ ? '[' + [].join.call(keyPath, '+') + ']'
3046
+ : '';
2829
3047
  }
2830
3048
 
2831
3049
  function createTableSchema(name, primKey, indexes) {
@@ -2861,16 +3079,16 @@ function getKeyExtractor(keyPath) {
2861
3079
  return getSinglePathKeyExtractor(keyPath);
2862
3080
  }
2863
3081
  else {
2864
- return obj => getByKeyPath(obj, keyPath);
3082
+ return (obj) => getByKeyPath(obj, keyPath);
2865
3083
  }
2866
3084
  }
2867
3085
  function getSinglePathKeyExtractor(keyPath) {
2868
3086
  const split = keyPath.split('.');
2869
3087
  if (split.length === 1) {
2870
- return obj => obj[keyPath];
3088
+ return (obj) => obj[keyPath];
2871
3089
  }
2872
3090
  else {
2873
- return obj => getByKeyPath(obj, keyPath);
3091
+ return (obj) => getByKeyPath(obj, keyPath);
2874
3092
  }
2875
3093
  }
2876
3094
 
@@ -2879,22 +3097,22 @@ function arrayify(arrayLike) {
2879
3097
  }
2880
3098
  let _id_counter = 0;
2881
3099
  function getKeyPathAlias(keyPath) {
2882
- return keyPath == null ?
2883
- ":id" :
2884
- typeof keyPath === 'string' ?
2885
- keyPath :
2886
- `[${keyPath.join('+')}]`;
3100
+ return keyPath == null
3101
+ ? ':id'
3102
+ : typeof keyPath === 'string'
3103
+ ? keyPath
3104
+ : `[${keyPath.join('+')}]`;
2887
3105
  }
2888
3106
  function createDBCore(db, IdbKeyRange, tmpTrans) {
2889
3107
  function extractSchema(db, trans) {
2890
3108
  const tables = arrayify(db.objectStoreNames);
2891
- const tempStore = tables.length > 0
2892
- ? trans.objectStore(tables[0])
2893
- : {};
3109
+ const tempStore = tables.length > 0 ? trans.objectStore(tables[0]) : {};
2894
3110
  return {
2895
3111
  schema: {
2896
3112
  name: db.name,
2897
- tables: tables.map(table => trans.objectStore(table)).map(store => {
3113
+ tables: tables
3114
+ .map((table) => trans.objectStore(table))
3115
+ .map((store) => {
2898
3116
  const { keyPath, autoIncrement } = store;
2899
3117
  const compound = isArray(keyPath);
2900
3118
  const outbound = keyPath == null;
@@ -2909,10 +3127,11 @@ function createDBCore(db, IdbKeyRange, tmpTrans) {
2909
3127
  keyPath,
2910
3128
  autoIncrement,
2911
3129
  unique: true,
2912
- extractKey: getKeyExtractor(keyPath)
3130
+ extractKey: getKeyExtractor(keyPath),
2913
3131
  },
2914
- indexes: arrayify(store.indexNames).map(indexName => store.index(indexName))
2915
- .map(index => {
3132
+ indexes: arrayify(store.indexNames)
3133
+ .map((indexName) => store.index(indexName))
3134
+ .map((index) => {
2916
3135
  const { name, unique, multiEntry, keyPath } = index;
2917
3136
  const compound = isArray(keyPath);
2918
3137
  const result = {
@@ -2921,40 +3140,42 @@ function createDBCore(db, IdbKeyRange, tmpTrans) {
2921
3140
  keyPath,
2922
3141
  unique,
2923
3142
  multiEntry,
2924
- extractKey: getKeyExtractor(keyPath)
3143
+ extractKey: getKeyExtractor(keyPath),
2925
3144
  };
2926
3145
  indexByKeyPath[getKeyPathAlias(keyPath)] = result;
2927
3146
  return result;
2928
3147
  }),
2929
- getIndexByKeyPath: (keyPath) => indexByKeyPath[getKeyPathAlias(keyPath)]
3148
+ getIndexByKeyPath: (keyPath) => indexByKeyPath[getKeyPathAlias(keyPath)],
2930
3149
  };
2931
- indexByKeyPath[":id"] = result.primaryKey;
3150
+ indexByKeyPath[':id'] = result.primaryKey;
2932
3151
  if (keyPath != null) {
2933
3152
  indexByKeyPath[getKeyPathAlias(keyPath)] = result.primaryKey;
2934
3153
  }
2935
3154
  return result;
2936
- })
3155
+ }),
2937
3156
  },
2938
- hasGetAll: tables.length > 0 && ('getAll' in tempStore) &&
2939
- !(typeof navigator !== 'undefined' && /Safari/.test(navigator.userAgent) &&
3157
+ hasGetAll: tables.length > 0 &&
3158
+ 'getAll' in tempStore &&
3159
+ !(typeof navigator !== 'undefined' &&
3160
+ /Safari/.test(navigator.userAgent) &&
2940
3161
  !/(Chrome\/|Edge\/)/.test(navigator.userAgent) &&
2941
3162
  [].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1] < 604),
2942
- hasIdb3Features: 'getAllRecords' in tempStore
3163
+ hasIdb3Features: 'getAllRecords' in tempStore,
2943
3164
  };
2944
3165
  }
2945
3166
  function makeIDBKeyRange(range) {
2946
3167
  if (range.type === 3 )
2947
3168
  return null;
2948
3169
  if (range.type === 4 )
2949
- throw new Error("Cannot convert never type to IDBKeyRange");
3170
+ throw new Error('Cannot convert never type to IDBKeyRange');
2950
3171
  const { lower, upper, lowerOpen, upperOpen } = range;
2951
- const idbRange = lower === undefined ?
2952
- upper === undefined ?
2953
- null :
2954
- IdbKeyRange.upperBound(upper, !!upperOpen) :
2955
- upper === undefined ?
2956
- IdbKeyRange.lowerBound(lower, !!lowerOpen) :
2957
- IdbKeyRange.bound(lower, upper, !!lowerOpen, !!upperOpen);
3172
+ const idbRange = lower === undefined
3173
+ ? upper === undefined
3174
+ ? null
3175
+ : IdbKeyRange.upperBound(upper, !!upperOpen)
3176
+ : upper === undefined
3177
+ ? IdbKeyRange.lowerBound(lower, !!lowerOpen)
3178
+ : IdbKeyRange.bound(lower, upper, !!lowerOpen, !!upperOpen);
2958
3179
  return idbRange;
2959
3180
  }
2960
3181
  function createDbCoreTable(tableSchema) {
@@ -2964,89 +3185,97 @@ function createDBCore(db, IdbKeyRange, tmpTrans) {
2964
3185
  resolve = wrap(resolve);
2965
3186
  const store = trans.objectStore(tableName);
2966
3187
  const outbound = store.keyPath == null;
2967
- const isAddOrPut = type === "put" || type === "add";
3188
+ const isAddOrPut = type === 'put' || type === 'add';
2968
3189
  if (!isAddOrPut && type !== 'delete' && type !== 'deleteRange')
2969
- throw new Error("Invalid operation type: " + type);
3190
+ throw new Error('Invalid operation type: ' + type);
2970
3191
  const { length } = keys || values || { length: 1 };
2971
3192
  if (keys && values && keys.length !== values.length) {
2972
- throw new Error("Given keys array must have same length as given values array.");
3193
+ throw new Error('Given keys array must have same length as given values array.');
2973
3194
  }
2974
3195
  if (length === 0)
2975
- return resolve({ numFailures: 0, failures: {}, results: [], lastResult: undefined });
3196
+ return resolve({
3197
+ numFailures: 0,
3198
+ failures: {},
3199
+ results: [],
3200
+ lastResult: undefined,
3201
+ });
2976
3202
  let req;
2977
3203
  const reqs = [];
2978
3204
  const failures = [];
2979
3205
  let numFailures = 0;
2980
- const errorHandler = event => {
3206
+ const errorHandler = (event) => {
2981
3207
  ++numFailures;
2982
3208
  preventDefault(event);
2983
3209
  };
2984
3210
  if (type === 'deleteRange') {
2985
3211
  if (range.type === 4 )
2986
- return resolve({ numFailures, failures, results: [], lastResult: undefined });
3212
+ return resolve({
3213
+ numFailures,
3214
+ failures,
3215
+ results: [],
3216
+ lastResult: undefined,
3217
+ });
2987
3218
  if (range.type === 3 )
2988
- reqs.push(req = store.clear());
3219
+ reqs.push((req = store.clear()));
2989
3220
  else
2990
- reqs.push(req = store.delete(makeIDBKeyRange(range)));
3221
+ reqs.push((req = store.delete(makeIDBKeyRange(range))));
2991
3222
  }
2992
3223
  else {
2993
- const [args1, args2] = isAddOrPut ?
2994
- outbound ?
2995
- [values, keys] :
2996
- [values, null] :
2997
- [keys, null];
3224
+ const [args1, args2] = isAddOrPut
3225
+ ? outbound
3226
+ ? [values, keys]
3227
+ : [values, null]
3228
+ : [keys, null];
2998
3229
  if (isAddOrPut) {
2999
3230
  for (let i = 0; i < length; ++i) {
3000
- reqs.push(req = (args2 && args2[i] !== undefined ?
3001
- store[type](args1[i], args2[i]) :
3002
- store[type](args1[i])));
3231
+ reqs.push((req = (args2 && args2[i] !== undefined
3232
+ ? store[type](args1[i], args2[i])
3233
+ : store[type](args1[i]))));
3003
3234
  req.onerror = errorHandler;
3004
3235
  }
3005
3236
  }
3006
3237
  else {
3007
3238
  for (let i = 0; i < length; ++i) {
3008
- reqs.push(req = store[type](args1[i]));
3239
+ reqs.push((req = store[type](args1[i])));
3009
3240
  req.onerror = errorHandler;
3010
3241
  }
3011
3242
  }
3012
3243
  }
3013
- const done = event => {
3244
+ const done = (event) => {
3014
3245
  const lastResult = event.target.result;
3015
3246
  reqs.forEach((req, i) => req.error != null && (failures[i] = req.error));
3016
3247
  resolve({
3017
3248
  numFailures,
3018
3249
  failures,
3019
- results: type === "delete" ? keys : reqs.map(req => req.result),
3020
- lastResult
3250
+ results: type === 'delete' ? keys : reqs.map((req) => req.result),
3251
+ lastResult,
3021
3252
  });
3022
3253
  };
3023
- req.onerror = event => {
3254
+ req.onerror = (event) => {
3024
3255
  errorHandler(event);
3025
3256
  done(event);
3026
3257
  };
3027
3258
  req.onsuccess = done;
3028
3259
  });
3029
3260
  }
3030
- function openCursor({ trans, values, query, reverse, unique }) {
3261
+ function openCursor({ trans, values, query, reverse, unique, }) {
3031
3262
  return new Promise((resolve, reject) => {
3032
3263
  resolve = wrap(resolve);
3033
3264
  const { index, range } = query;
3034
3265
  const store = trans.objectStore(tableName);
3035
- const source = index.isPrimaryKey ?
3036
- store :
3037
- store.index(index.name);
3038
- const direction = reverse ?
3039
- unique ?
3040
- "prevunique" :
3041
- "prev" :
3042
- unique ?
3043
- "nextunique" :
3044
- "next";
3045
- const req = values || !('openKeyCursor' in source) ?
3046
- source.openCursor(makeIDBKeyRange(range), direction) :
3047
- source.openKeyCursor(makeIDBKeyRange(range), direction);
3266
+ const source = index.isPrimaryKey ? store : store.index(index.name);
3267
+ const direction = reverse
3268
+ ? unique
3269
+ ? 'prevunique'
3270
+ : 'prev'
3271
+ : unique
3272
+ ? 'nextunique'
3273
+ : 'next';
3274
+ const req = values || !('openKeyCursor' in source)
3275
+ ? source.openCursor(makeIDBKeyRange(range), direction)
3276
+ : source.openKeyCursor(makeIDBKeyRange(range), direction);
3048
3277
  req.onerror = eventRejectHandler(reject);
3049
- req.onsuccess = wrap(ev => {
3278
+ req.onsuccess = wrap((ev) => {
3050
3279
  const cursor = req.result;
3051
3280
  if (!cursor) {
3052
3281
  resolve(null);
@@ -3059,10 +3288,18 @@ function createDBCore(db, IdbKeyRange, tmpTrans) {
3059
3288
  if (_cursorContinuePrimaryKey)
3060
3289
  _cursorContinuePrimaryKey = _cursorContinuePrimaryKey.bind(cursor);
3061
3290
  const _cursorAdvance = cursor.advance.bind(cursor);
3062
- const doThrowCursorIsNotStarted = () => { throw new Error("Cursor not started"); };
3063
- const doThrowCursorIsStopped = () => { throw new Error("Cursor not stopped"); };
3291
+ const doThrowCursorIsNotStarted = () => {
3292
+ throw new Error('Cursor not started');
3293
+ };
3294
+ const doThrowCursorIsStopped = () => {
3295
+ throw new Error('Cursor not stopped');
3296
+ };
3064
3297
  cursor.trans = trans;
3065
- cursor.stop = cursor.continue = cursor.continuePrimaryKey = cursor.advance = doThrowCursorIsNotStarted;
3298
+ cursor.stop =
3299
+ cursor.continue =
3300
+ cursor.continuePrimaryKey =
3301
+ cursor.advance =
3302
+ doThrowCursorIsNotStarted;
3066
3303
  cursor.fail = wrap(reject);
3067
3304
  cursor.next = function () {
3068
3305
  let gotOne = 1;
@@ -3073,8 +3310,12 @@ function createDBCore(db, IdbKeyRange, tmpTrans) {
3073
3310
  resolveIteration = wrap(resolveIteration);
3074
3311
  req.onerror = eventRejectHandler(rejectIteration);
3075
3312
  cursor.fail = rejectIteration;
3076
- cursor.stop = value => {
3077
- cursor.stop = cursor.continue = cursor.continuePrimaryKey = cursor.advance = doThrowCursorIsStopped;
3313
+ cursor.stop = (value) => {
3314
+ cursor.stop =
3315
+ cursor.continue =
3316
+ cursor.continuePrimaryKey =
3317
+ cursor.advance =
3318
+ doThrowCursorIsStopped;
3078
3319
  resolveIteration(value);
3079
3320
  };
3080
3321
  });
@@ -3089,11 +3330,13 @@ function createDBCore(db, IdbKeyRange, tmpTrans) {
3089
3330
  }
3090
3331
  else {
3091
3332
  cursor.done = true;
3092
- cursor.start = () => { throw new Error("Cursor behind last entry"); };
3333
+ cursor.start = () => {
3334
+ throw new Error('Cursor behind last entry');
3335
+ };
3093
3336
  cursor.stop();
3094
3337
  }
3095
3338
  };
3096
- req.onsuccess = wrap(ev => {
3339
+ req.onsuccess = wrap((ev) => {
3097
3340
  req.onsuccess = guardedCallback;
3098
3341
  guardedCallback();
3099
3342
  });
@@ -3124,26 +3367,26 @@ function createDBCore(db, IdbKeyRange, tmpTrans) {
3124
3367
  const options = {
3125
3368
  query: idbKeyRange,
3126
3369
  count: nonInfinitLimit,
3127
- direction
3370
+ direction,
3128
3371
  };
3129
- const req = values ?
3130
- source.getAll(options) :
3131
- source.getAllKeys(options);
3132
- req.onsuccess = event => resolve({ result: event.target.result });
3372
+ const req = values
3373
+ ? source.getAll(options)
3374
+ : source.getAllKeys(options);
3375
+ req.onsuccess = (event) => resolve({ result: event.target.result });
3133
3376
  req.onerror = eventRejectHandler(reject);
3134
3377
  }
3135
3378
  else if (hasGetAll && direction === 'next') {
3136
- const req = values ?
3137
- source.getAll(idbKeyRange, nonInfinitLimit) :
3138
- source.getAllKeys(idbKeyRange, nonInfinitLimit);
3379
+ const req = values
3380
+ ? source.getAll(idbKeyRange, nonInfinitLimit)
3381
+ : source.getAllKeys(idbKeyRange, nonInfinitLimit);
3139
3382
  req.onsuccess = (event) => resolve({ result: event.target.result });
3140
3383
  req.onerror = eventRejectHandler(reject);
3141
3384
  }
3142
3385
  else {
3143
3386
  let count = 0;
3144
- const req = values || !('openKeyCursor' in source) ?
3145
- source.openCursor(idbKeyRange, direction) :
3146
- source.openKeyCursor(idbKeyRange, direction);
3387
+ const req = values || !('openKeyCursor' in source)
3388
+ ? source.openCursor(idbKeyRange, direction)
3389
+ : source.openKeyCursor(idbKeyRange, direction);
3147
3390
  const result = [];
3148
3391
  req.onsuccess = () => {
3149
3392
  const cursor = req.result;
@@ -3172,7 +3415,7 @@ function createDBCore(db, IdbKeyRange, tmpTrans) {
3172
3415
  let keyCount = 0;
3173
3416
  let callbackCount = 0;
3174
3417
  let req;
3175
- const successHandler = event => {
3418
+ const successHandler = (event) => {
3176
3419
  const req = event.target;
3177
3420
  if ((result[req._pos] = req.result) != null)
3178
3421
  ;
@@ -3199,7 +3442,7 @@ function createDBCore(db, IdbKeyRange, tmpTrans) {
3199
3442
  resolve = wrap(resolve);
3200
3443
  const store = trans.objectStore(tableName);
3201
3444
  const req = store.get(key);
3202
- req.onsuccess = event => resolve(event.target.result);
3445
+ req.onsuccess = (event) => resolve(event.target.result);
3203
3446
  req.onerror = eventRejectHandler(reject);
3204
3447
  });
3205
3448
  },
@@ -3212,18 +3455,18 @@ function createDBCore(db, IdbKeyRange, tmpTrans) {
3212
3455
  const source = index.isPrimaryKey ? store : store.index(index.name);
3213
3456
  const idbKeyRange = makeIDBKeyRange(range);
3214
3457
  const req = idbKeyRange ? source.count(idbKeyRange) : source.count();
3215
- req.onsuccess = wrap(ev => resolve(ev.target.result));
3458
+ req.onsuccess = wrap((ev) => resolve(ev.target.result));
3216
3459
  req.onerror = eventRejectHandler(reject);
3217
3460
  });
3218
- }
3461
+ },
3219
3462
  };
3220
3463
  }
3221
3464
  const { schema, hasGetAll, hasIdb3Features } = extractSchema(db, tmpTrans);
3222
- const tables = schema.tables.map(tableSchema => createDbCoreTable(tableSchema));
3465
+ const tables = schema.tables.map((tableSchema) => createDbCoreTable(tableSchema));
3223
3466
  const tableMap = {};
3224
- tables.forEach(table => tableMap[table.name] = table);
3467
+ tables.forEach((table) => (tableMap[table.name] = table));
3225
3468
  return {
3226
- stack: "dbcore",
3469
+ stack: 'dbcore',
3227
3470
  transaction: db.transaction.bind(db),
3228
3471
  table(name) {
3229
3472
  const result = tableMap[name];
@@ -3233,7 +3476,7 @@ function createDBCore(db, IdbKeyRange, tmpTrans) {
3233
3476
  },
3234
3477
  MIN_KEY: -Infinity,
3235
3478
  MAX_KEY: getMaxKey(IdbKeyRange),
3236
- schema
3479
+ schema,
3237
3480
  };
3238
3481
  }
3239
3482
 
@@ -3243,16 +3486,16 @@ function createMiddlewareStack(stackImpl, middlewares) {
3243
3486
  function createMiddlewareStacks(middlewares, idbdb, { IDBKeyRange, indexedDB }, tmpTrans) {
3244
3487
  const dbcore = createMiddlewareStack(createDBCore(idbdb, IDBKeyRange, tmpTrans), middlewares.dbcore);
3245
3488
  return {
3246
- dbcore
3489
+ dbcore,
3247
3490
  };
3248
3491
  }
3249
3492
  function generateMiddlewareStacks(db, tmpTrans) {
3250
3493
  const idbdb = tmpTrans.db;
3251
3494
  const stacks = createMiddlewareStacks(db._middlewares, idbdb, db._deps, tmpTrans);
3252
3495
  db.core = stacks.dbcore;
3253
- db.tables.forEach(table => {
3496
+ db.tables.forEach((table) => {
3254
3497
  const tableName = table.name;
3255
- if (db.core.schema.tables.some(tbl => tbl.name === tableName)) {
3498
+ if (db.core.schema.tables.some((tbl) => tbl.name === tableName)) {
3256
3499
  table.core = db.core.table(tableName);
3257
3500
  if (db[tableName] instanceof db.Table) {
3258
3501
  db[tableName].core = table.core;
@@ -3262,17 +3505,24 @@ function generateMiddlewareStacks(db, tmpTrans) {
3262
3505
  }
3263
3506
 
3264
3507
  function setApiOnPlace(db, objs, tableNames, dbschema) {
3265
- tableNames.forEach(tableName => {
3508
+ tableNames.forEach((tableName) => {
3266
3509
  const schema = dbschema[tableName];
3267
- objs.forEach(obj => {
3510
+ objs.forEach((obj) => {
3268
3511
  const propDesc = getPropertyDescriptor(obj, tableName);
3269
- if (!propDesc || ("value" in propDesc && propDesc.value === undefined)) {
3512
+ if (!propDesc || ('value' in propDesc && propDesc.value === undefined)) {
3270
3513
  if (obj === db.Transaction.prototype || obj instanceof db.Transaction) {
3271
3514
  setProp(obj, tableName, {
3272
- get() { return this.table(tableName); },
3515
+ get() {
3516
+ return this.table(tableName);
3517
+ },
3273
3518
  set(value) {
3274
- defineProperty(this, tableName, { value, writable: true, configurable: true, enumerable: true });
3275
- }
3519
+ defineProperty(this, tableName, {
3520
+ value,
3521
+ writable: true,
3522
+ configurable: true,
3523
+ enumerable: true,
3524
+ });
3525
+ },
3276
3526
  });
3277
3527
  }
3278
3528
  else {
@@ -3283,7 +3533,7 @@ function setApiOnPlace(db, objs, tableNames, dbschema) {
3283
3533
  });
3284
3534
  }
3285
3535
  function removeTablesApi(db, objs) {
3286
- objs.forEach(obj => {
3536
+ objs.forEach((obj) => {
3287
3537
  for (let key in obj) {
3288
3538
  if (obj[key] instanceof db.Table)
3289
3539
  delete obj[key];
@@ -3295,8 +3545,9 @@ function lowerVersionFirst(a, b) {
3295
3545
  }
3296
3546
  function runUpgraders(db, oldVersion, idbUpgradeTrans, reject) {
3297
3547
  const globalSchema = db._dbSchema;
3298
- if (idbUpgradeTrans.objectStoreNames.contains('$meta') && !globalSchema.$meta) {
3299
- globalSchema.$meta = createTableSchema("$meta", parseIndexSyntax("")[0], []);
3548
+ if (idbUpgradeTrans.objectStoreNames.contains('$meta') &&
3549
+ !globalSchema.$meta) {
3550
+ globalSchema.$meta = createTableSchema('$meta', parseIndexSyntax('')[0], []);
3300
3551
  db._storeNames.push('$meta');
3301
3552
  }
3302
3553
  const trans = db._createTransaction('readwrite', db._storeNames, globalSchema);
@@ -3308,7 +3559,7 @@ function runUpgraders(db, oldVersion, idbUpgradeTrans, reject) {
3308
3559
  PSD.trans = trans;
3309
3560
  PSD.transless = transless;
3310
3561
  if (oldVersion === 0) {
3311
- keys(globalSchema).forEach(tableName => {
3562
+ keys(globalSchema).forEach((tableName) => {
3312
3563
  createTable(idbUpgradeTrans, tableName, globalSchema[tableName].primKey, globalSchema[tableName].indexes);
3313
3564
  });
3314
3565
  generateMiddlewareStacks(db, idbUpgradeTrans);
@@ -3317,15 +3568,18 @@ function runUpgraders(db, oldVersion, idbUpgradeTrans, reject) {
3317
3568
  else {
3318
3569
  generateMiddlewareStacks(db, idbUpgradeTrans);
3319
3570
  return getExistingVersion(db, trans, oldVersion)
3320
- .then(oldVersion => updateTablesAndIndexes(db, oldVersion, trans, idbUpgradeTrans))
3571
+ .then((oldVersion) => updateTablesAndIndexes(db, oldVersion, trans, idbUpgradeTrans))
3321
3572
  .catch(rejectTransaction);
3322
3573
  }
3323
3574
  });
3324
3575
  }
3325
3576
  function patchCurrentVersion(db, idbUpgradeTrans) {
3326
3577
  createMissingTables(db._dbSchema, idbUpgradeTrans);
3327
- if (idbUpgradeTrans.db.version % 10 === 0 && !idbUpgradeTrans.objectStoreNames.contains('$meta')) {
3328
- idbUpgradeTrans.db.createObjectStore('$meta').add(Math.ceil((idbUpgradeTrans.db.version / 10) - 1), 'version');
3578
+ if (idbUpgradeTrans.db.version % 10 === 0 &&
3579
+ !idbUpgradeTrans.objectStoreNames.contains('$meta')) {
3580
+ idbUpgradeTrans.db
3581
+ .createObjectStore('$meta')
3582
+ .add(Math.ceil(idbUpgradeTrans.db.version / 10 - 1), 'version');
3329
3583
  }
3330
3584
  const globalSchema = buildGlobalSchema(db, db.idbdb, idbUpgradeTrans);
3331
3585
  adjustToExistingIndexNames(db, db._dbSchema, idbUpgradeTrans);
@@ -3336,7 +3590,7 @@ function patchCurrentVersion(db, idbUpgradeTrans) {
3336
3590
  return;
3337
3591
  }
3338
3592
  const store = idbUpgradeTrans.objectStore(tableChange.name);
3339
- tableChange.add.forEach(idx => {
3593
+ tableChange.add.forEach((idx) => {
3340
3594
  if (debug)
3341
3595
  console.debug(`Dexie upgrade patch: Creating missing index ${tableChange.name}.${idx.src}`);
3342
3596
  addIndex(store, idx);
@@ -3345,7 +3599,10 @@ function patchCurrentVersion(db, idbUpgradeTrans) {
3345
3599
  }
3346
3600
  function getExistingVersion(db, trans, oldVersion) {
3347
3601
  if (trans.storeNames.includes('$meta')) {
3348
- return trans.table('$meta').get('version').then(metaVersion => {
3602
+ return trans
3603
+ .table('$meta')
3604
+ .get('version')
3605
+ .then((metaVersion) => {
3349
3606
  return metaVersion != null ? metaVersion : oldVersion;
3350
3607
  });
3351
3608
  }
@@ -3356,12 +3613,12 @@ function getExistingVersion(db, trans, oldVersion) {
3356
3613
  function updateTablesAndIndexes(db, oldVersion, trans, idbUpgradeTrans) {
3357
3614
  const queue = [];
3358
3615
  const versions = db._versions;
3359
- let globalSchema = db._dbSchema = buildGlobalSchema(db, db.idbdb, idbUpgradeTrans);
3360
- const versToRun = versions.filter(v => v._cfg.version >= oldVersion);
3616
+ let globalSchema = (db._dbSchema = buildGlobalSchema(db, db.idbdb, idbUpgradeTrans));
3617
+ const versToRun = versions.filter((v) => v._cfg.version >= oldVersion);
3361
3618
  if (versToRun.length === 0) {
3362
3619
  return DexiePromise.resolve();
3363
3620
  }
3364
- versToRun.forEach(version => {
3621
+ versToRun.forEach((version) => {
3365
3622
  queue.push(() => {
3366
3623
  const oldSchema = globalSchema;
3367
3624
  const newSchema = version._cfg.dbschema;
@@ -3369,21 +3626,21 @@ function updateTablesAndIndexes(db, oldVersion, trans, idbUpgradeTrans) {
3369
3626
  adjustToExistingIndexNames(db, newSchema, idbUpgradeTrans);
3370
3627
  globalSchema = db._dbSchema = newSchema;
3371
3628
  const diff = getSchemaDiff(oldSchema, newSchema);
3372
- diff.add.forEach(tuple => {
3629
+ diff.add.forEach((tuple) => {
3373
3630
  createTable(idbUpgradeTrans, tuple[0], tuple[1].primKey, tuple[1].indexes);
3374
3631
  });
3375
- diff.change.forEach(change => {
3632
+ diff.change.forEach((change) => {
3376
3633
  if (change.recreate) {
3377
- throw new exceptions.Upgrade("Not yet support for changing primary key");
3634
+ throw new exceptions.Upgrade('Not yet support for changing primary key');
3378
3635
  }
3379
3636
  else {
3380
3637
  const store = idbUpgradeTrans.objectStore(change.name);
3381
- change.add.forEach(idx => addIndex(store, idx));
3382
- change.change.forEach(idx => {
3638
+ change.add.forEach((idx) => addIndex(store, idx));
3639
+ change.change.forEach((idx) => {
3383
3640
  store.deleteIndex(idx.name);
3384
3641
  addIndex(store, idx);
3385
3642
  });
3386
- change.del.forEach(idxName => store.deleteIndex(idxName));
3643
+ change.del.forEach((idxName) => store.deleteIndex(idxName));
3387
3644
  }
3388
3645
  });
3389
3646
  const contentUpgrade = version._cfg.contentUpgrade;
@@ -3391,7 +3648,7 @@ function updateTablesAndIndexes(db, oldVersion, trans, idbUpgradeTrans) {
3391
3648
  generateMiddlewareStacks(db, idbUpgradeTrans);
3392
3649
  trans._memoizedTables = {};
3393
3650
  let upgradeSchema = shallowClone(newSchema);
3394
- diff.del.forEach(table => {
3651
+ diff.del.forEach((table) => {
3395
3652
  upgradeSchema[table] = oldSchema[table];
3396
3653
  });
3397
3654
  removeTablesApi(db, [db.Transaction.prototype]);
@@ -3411,23 +3668,24 @@ function updateTablesAndIndexes(db, oldVersion, trans, idbUpgradeTrans) {
3411
3668
  }
3412
3669
  }
3413
3670
  });
3414
- return (returnValue && typeof returnValue.then === 'function' ?
3415
- DexiePromise.resolve(returnValue) : promiseFollowed.then(() => returnValue));
3671
+ return returnValue && typeof returnValue.then === 'function'
3672
+ ? DexiePromise.resolve(returnValue)
3673
+ : promiseFollowed.then(() => returnValue);
3416
3674
  }
3417
3675
  });
3418
- queue.push(idbtrans => {
3676
+ queue.push((idbtrans) => {
3419
3677
  const newSchema = version._cfg.dbschema;
3420
3678
  deleteRemovedTables(newSchema, idbtrans);
3421
3679
  removeTablesApi(db, [db.Transaction.prototype]);
3422
3680
  setApiOnPlace(db, [db.Transaction.prototype], db._storeNames, db._dbSchema);
3423
3681
  trans.schema = db._dbSchema;
3424
3682
  });
3425
- queue.push(idbtrans => {
3683
+ queue.push((idbtrans) => {
3426
3684
  if (db.idbdb.objectStoreNames.contains('$meta')) {
3427
3685
  if (Math.ceil(db.idbdb.version / 10) === version._cfg.version) {
3428
3686
  db.idbdb.deleteObjectStore('$meta');
3429
3687
  delete db._dbSchema.$meta;
3430
- db._storeNames = db._storeNames.filter(name => name !== '$meta');
3688
+ db._storeNames = db._storeNames.filter((name) => name !== '$meta');
3431
3689
  }
3432
3690
  else {
3433
3691
  idbtrans.objectStore('$meta').put(version._cfg.version, 'version');
@@ -3436,8 +3694,9 @@ function updateTablesAndIndexes(db, oldVersion, trans, idbUpgradeTrans) {
3436
3694
  });
3437
3695
  });
3438
3696
  function runQueue() {
3439
- return queue.length ? DexiePromise.resolve(queue.shift()(trans.idbtrans)).then(runQueue) :
3440
- DexiePromise.resolve();
3697
+ return queue.length
3698
+ ? DexiePromise.resolve(queue.shift()(trans.idbtrans)).then(runQueue)
3699
+ : DexiePromise.resolve();
3441
3700
  }
3442
3701
  return runQueue().then(() => {
3443
3702
  createMissingTables(globalSchema, idbUpgradeTrans);
@@ -3447,7 +3706,7 @@ function getSchemaDiff(oldSchema, newSchema) {
3447
3706
  const diff = {
3448
3707
  del: [],
3449
3708
  add: [],
3450
- change: []
3709
+ change: [],
3451
3710
  };
3452
3711
  let table;
3453
3712
  for (table in oldSchema) {
@@ -3466,11 +3725,12 @@ function getSchemaDiff(oldSchema, newSchema) {
3466
3725
  recreate: false,
3467
3726
  del: [],
3468
3727
  add: [],
3469
- change: []
3728
+ change: [],
3470
3729
  };
3471
- if ((
3472
- '' + (oldDef.primKey.keyPath || '')) !== ('' + (newDef.primKey.keyPath || '')) ||
3473
- (oldDef.primKey.auto !== newDef.primKey.auto)) {
3730
+ if (
3731
+ '' + (oldDef.primKey.keyPath || '') !==
3732
+ '' + (newDef.primKey.keyPath || '') ||
3733
+ oldDef.primKey.auto !== newDef.primKey.auto) {
3474
3734
  change.recreate = true;
3475
3735
  diff.change.push(change);
3476
3736
  }
@@ -3489,7 +3749,9 @@ function getSchemaDiff(oldSchema, newSchema) {
3489
3749
  else if (oldIdx.src !== newIdx.src)
3490
3750
  change.change.push(newIdx);
3491
3751
  }
3492
- if (change.del.length > 0 || change.add.length > 0 || change.change.length > 0) {
3752
+ if (change.del.length > 0 ||
3753
+ change.add.length > 0 ||
3754
+ change.change.length > 0) {
3493
3755
  diff.change.push(change);
3494
3756
  }
3495
3757
  }
@@ -3498,14 +3760,14 @@ function getSchemaDiff(oldSchema, newSchema) {
3498
3760
  return diff;
3499
3761
  }
3500
3762
  function createTable(idbtrans, tableName, primKey, indexes) {
3501
- const store = idbtrans.db.createObjectStore(tableName, primKey.keyPath ?
3502
- { keyPath: primKey.keyPath, autoIncrement: primKey.auto } :
3503
- { autoIncrement: primKey.auto });
3504
- indexes.forEach(idx => addIndex(store, idx));
3763
+ const store = idbtrans.db.createObjectStore(tableName, primKey.keyPath
3764
+ ? { keyPath: primKey.keyPath, autoIncrement: primKey.auto }
3765
+ : { autoIncrement: primKey.auto });
3766
+ indexes.forEach((idx) => addIndex(store, idx));
3505
3767
  return store;
3506
3768
  }
3507
3769
  function createMissingTables(newSchema, idbtrans) {
3508
- keys(newSchema).forEach(tableName => {
3770
+ keys(newSchema).forEach((tableName) => {
3509
3771
  if (!idbtrans.db.objectStoreNames.contains(tableName)) {
3510
3772
  if (debug)
3511
3773
  console.debug('Dexie: Creating missing table', tableName);
@@ -3514,23 +3776,28 @@ function createMissingTables(newSchema, idbtrans) {
3514
3776
  });
3515
3777
  }
3516
3778
  function deleteRemovedTables(newSchema, idbtrans) {
3517
- [].slice.call(idbtrans.db.objectStoreNames).forEach(storeName => newSchema[storeName] == null && idbtrans.db.deleteObjectStore(storeName));
3779
+ [].slice
3780
+ .call(idbtrans.db.objectStoreNames)
3781
+ .forEach((storeName) => newSchema[storeName] == null && idbtrans.db.deleteObjectStore(storeName));
3518
3782
  }
3519
3783
  function addIndex(store, idx) {
3520
- store.createIndex(idx.name, idx.keyPath, { unique: idx.unique, multiEntry: idx.multi });
3784
+ store.createIndex(idx.name, idx.keyPath, {
3785
+ unique: idx.unique,
3786
+ multiEntry: idx.multi,
3787
+ });
3521
3788
  }
3522
3789
  function buildGlobalSchema(db, idbdb, tmpTrans) {
3523
3790
  const globalSchema = {};
3524
3791
  const dbStoreNames = slice(idbdb.objectStoreNames, 0);
3525
- dbStoreNames.forEach(storeName => {
3792
+ dbStoreNames.forEach((storeName) => {
3526
3793
  const store = tmpTrans.objectStore(storeName);
3527
3794
  let keyPath = store.keyPath;
3528
- const primKey = createIndexSpec(nameFromKeyPath(keyPath), keyPath || "", true, false, !!store.autoIncrement, keyPath && typeof keyPath !== "string", true);
3795
+ const primKey = createIndexSpec(nameFromKeyPath(keyPath), keyPath || '', true, false, !!store.autoIncrement, keyPath && typeof keyPath !== 'string', true);
3529
3796
  const indexes = [];
3530
3797
  for (let j = 0; j < store.indexNames.length; ++j) {
3531
3798
  const idbindex = store.index(store.indexNames[j]);
3532
3799
  keyPath = idbindex.keyPath;
3533
- var index = createIndexSpec(idbindex.name, keyPath, !!idbindex.unique, !!idbindex.multiEntry, false, keyPath && typeof keyPath !== "string", false);
3800
+ var index = createIndexSpec(idbindex.name, keyPath, !!idbindex.unique, !!idbindex.multiEntry, false, keyPath && typeof keyPath !== 'string', false);
3534
3801
  indexes.push(index);
3535
3802
  }
3536
3803
  globalSchema[storeName] = createTableSchema(storeName, primKey, indexes);
@@ -3539,14 +3806,15 @@ function buildGlobalSchema(db, idbdb, tmpTrans) {
3539
3806
  }
3540
3807
  function readGlobalSchema(db, idbdb, tmpTrans) {
3541
3808
  db.verno = idbdb.version / 10;
3542
- const globalSchema = db._dbSchema = buildGlobalSchema(db, idbdb, tmpTrans);
3809
+ const globalSchema = (db._dbSchema = buildGlobalSchema(db, idbdb, tmpTrans));
3543
3810
  db._storeNames = slice(idbdb.objectStoreNames, 0);
3544
3811
  setApiOnPlace(db, [db._allTables], keys(globalSchema), globalSchema);
3545
3812
  }
3546
3813
  function verifyInstalledSchema(db, tmpTrans) {
3547
3814
  const installedSchema = buildGlobalSchema(db, db.idbdb, tmpTrans);
3548
3815
  const diff = getSchemaDiff(installedSchema, db._dbSchema);
3549
- return !(diff.add.length || diff.change.some(ch => ch.add.length || ch.change.length));
3816
+ return !(diff.add.length ||
3817
+ diff.change.some((ch) => ch.add.length || ch.change.length));
3550
3818
  }
3551
3819
  function adjustToExistingIndexNames(db, schema, idbtrans) {
3552
3820
  const storeNames = idbtrans.db.objectStoreNames;
@@ -3557,7 +3825,9 @@ function adjustToExistingIndexNames(db, schema, idbtrans) {
3557
3825
  for (let j = 0; j < store.indexNames.length; ++j) {
3558
3826
  const indexName = store.indexNames[j];
3559
3827
  const keyPath = store.index(indexName).keyPath;
3560
- const dexieName = typeof keyPath === 'string' ? keyPath : "[" + slice(keyPath).join('+') + "]";
3828
+ const dexieName = typeof keyPath === 'string'
3829
+ ? keyPath
3830
+ : '[' + slice(keyPath).join('+') + ']';
3561
3831
  if (schema[storeName]) {
3562
3832
  const indexSpec = schema[storeName].idxByName[dexieName];
3563
3833
  if (indexSpec) {
@@ -3568,9 +3838,11 @@ function adjustToExistingIndexNames(db, schema, idbtrans) {
3568
3838
  }
3569
3839
  }
3570
3840
  }
3571
- if (typeof navigator !== 'undefined' && /Safari/.test(navigator.userAgent) &&
3841
+ if (typeof navigator !== 'undefined' &&
3842
+ /Safari/.test(navigator.userAgent) &&
3572
3843
  !/(Chrome\/|Edge\/)/.test(navigator.userAgent) &&
3573
- _global.WorkerGlobalScope && _global instanceof _global.WorkerGlobalScope &&
3844
+ _global.WorkerGlobalScope &&
3845
+ _global instanceof _global.WorkerGlobalScope &&
3574
3846
  [].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1] < 604) {
3575
3847
  db._hasGetAll = false;
3576
3848
  }
@@ -3580,8 +3852,10 @@ function parseIndexSyntax(primKeyAndIndexes) {
3580
3852
  const typeSplit = index.split(':');
3581
3853
  const type = typeSplit[1]?.trim();
3582
3854
  index = typeSplit[0].trim();
3583
- const name = index.replace(/([&*]|\+\+)/g, "");
3584
- const keyPath = /^\[/.test(name) ? name.match(/^\[(.*)\]$/)[1].split('+') : name;
3855
+ const name = index.replace(/([&*]|\+\+)/g, '');
3856
+ const keyPath = /^\[/.test(name)
3857
+ ? name.match(/^\[(.*)\]$/)[1].split('+')
3858
+ : name;
3585
3859
  return createIndexSpec(name, keyPath || null, /\&/.test(index), /\*/.test(index), /\+\+/.test(index), isArray(keyPath), indexNum === 0, type);
3586
3860
  });
3587
3861
  }
@@ -3648,21 +3922,22 @@ function createVersionConstructor(db) {
3648
3922
  storesSource: null,
3649
3923
  dbschema: {},
3650
3924
  tables: {},
3651
- contentUpgrade: null
3925
+ contentUpgrade: null,
3652
3926
  };
3653
3927
  });
3654
3928
  }
3655
3929
 
3656
3930
  const connections = createConnectionsManager();
3657
3931
  function createConnectionsManager() {
3658
- if (typeof FinalizationRegistry !== 'undefined' && typeof WeakRef !== 'undefined') {
3932
+ if (typeof FinalizationRegistry !== 'undefined' &&
3933
+ typeof WeakRef !== 'undefined') {
3659
3934
  const _refs = new Set();
3660
3935
  const _registry = new FinalizationRegistry((ref) => {
3661
3936
  _refs.delete(ref);
3662
3937
  });
3663
3938
  const toArray = () => {
3664
3939
  return Array.from(_refs)
3665
- .map(ref => ref.deref())
3940
+ .map((ref) => ref.deref())
3666
3941
  .filter((db) => db !== undefined);
3667
3942
  };
3668
3943
  const add = (db) => {
@@ -3711,19 +3986,19 @@ function createConnectionsManager() {
3711
3986
  }
3712
3987
 
3713
3988
  function getDbNamesTable(indexedDB, IDBKeyRange) {
3714
- let dbNamesDB = indexedDB["_dbNamesDB"];
3989
+ let dbNamesDB = indexedDB['_dbNamesDB'];
3715
3990
  if (!dbNamesDB) {
3716
- dbNamesDB = indexedDB["_dbNamesDB"] = new Dexie$1(DBNAMES_DB, {
3991
+ dbNamesDB = indexedDB['_dbNamesDB'] = new Dexie$1(DBNAMES_DB, {
3717
3992
  addons: [],
3718
3993
  indexedDB,
3719
3994
  IDBKeyRange,
3720
3995
  });
3721
- dbNamesDB.version(1).stores({ dbnames: "name" });
3996
+ dbNamesDB.version(1).stores({ dbnames: 'name' });
3722
3997
  }
3723
- return dbNamesDB.table("dbnames");
3998
+ return dbNamesDB.table('dbnames');
3724
3999
  }
3725
4000
  function hasDatabasesNative(indexedDB) {
3726
- return indexedDB && typeof indexedDB.databases === "function";
4001
+ return indexedDB && typeof indexedDB.databases === 'function';
3727
4002
  }
3728
4003
  function getDatabaseNames({ indexedDB, IDBKeyRange, }) {
3729
4004
  return hasDatabasesNative(indexedDB)
@@ -3765,15 +4040,17 @@ function idbReady() {
3765
4040
  }
3766
4041
 
3767
4042
  function isEmptyRange(node) {
3768
- return !("from" in node);
4043
+ return !('from' in node);
3769
4044
  }
3770
4045
  const RangeSet = function (fromOrTree, to) {
3771
4046
  if (this) {
3772
- extend(this, arguments.length ? { d: 1, from: fromOrTree, to: arguments.length > 1 ? to : fromOrTree } : { d: 0 });
4047
+ extend(this, arguments.length
4048
+ ? { d: 1, from: fromOrTree, to: arguments.length > 1 ? to : fromOrTree }
4049
+ : { d: 0 });
3773
4050
  }
3774
4051
  else {
3775
4052
  const rv = new RangeSet();
3776
- if (fromOrTree && ("d" in fromOrTree)) {
4053
+ if (fromOrTree && 'd' in fromOrTree) {
3777
4054
  extend(rv, fromOrTree);
3778
4055
  }
3779
4056
  return rv;
@@ -3789,7 +4066,7 @@ props(RangeSet.prototype, {
3789
4066
  return this;
3790
4067
  },
3791
4068
  addKeys(keys) {
3792
- keys.forEach(key => addRange(this, key, key));
4069
+ keys.forEach((key) => addRange(this, key, key));
3793
4070
  return this;
3794
4071
  },
3795
4072
  hasKey(key) {
@@ -3798,7 +4075,7 @@ props(RangeSet.prototype, {
3798
4075
  },
3799
4076
  [iteratorSymbol]() {
3800
4077
  return getRangeSetIterator(this);
3801
- }
4078
+ },
3802
4079
  });
3803
4080
  function addRange(target, from, to) {
3804
4081
  const diff = cmp(from, to);
@@ -3841,7 +4118,7 @@ function addRange(target, from, to) {
3841
4118
  }
3842
4119
  }
3843
4120
  function mergeRanges(target, newSet) {
3844
- function _addRangeSet(target, { from, to, l, r }) {
4121
+ function _addRangeSet(target, { from, to, l, r, }) {
3845
4122
  addRange(target, from, to);
3846
4123
  if (l)
3847
4124
  _addRangeSet(target, l);
@@ -3870,7 +4147,9 @@ function rangesOverlap(rangeSet1, rangeSet2) {
3870
4147
  return false;
3871
4148
  }
3872
4149
  function getRangeSetIterator(node) {
3873
- let state = isEmptyRange(node) ? null : { s: 0, n: node };
4150
+ let state = isEmptyRange(node)
4151
+ ? null
4152
+ : { s: 0, n: node };
3874
4153
  return {
3875
4154
  next(key) {
3876
4155
  const keyProvided = arguments.length > 0;
@@ -3906,9 +4185,9 @@ function getRangeSetIterator(node) {
3906
4185
  }
3907
4186
  function rebalance(target) {
3908
4187
  const diff = (target.r?.d || 0) - (target.l?.d || 0);
3909
- const r = diff > 1 ? "r" : diff < -1 ? "l" : "";
4188
+ const r = diff > 1 ? 'r' : diff < -1 ? 'l' : '';
3910
4189
  if (r) {
3911
- const l = r === "r" ? "l" : "r";
4190
+ const l = r === 'r' ? 'l' : 'r';
3912
4191
  const rootClone = { ...target };
3913
4192
  const oldRootRight = target[r];
3914
4193
  target.from = oldRootRight.from;
@@ -3925,7 +4204,7 @@ function computeDepth({ r, l }) {
3925
4204
  }
3926
4205
 
3927
4206
  function extendObservabilitySet(target, newSet) {
3928
- keys(newSet).forEach(part => {
4207
+ keys(newSet).forEach((part) => {
3929
4208
  if (target[part])
3930
4209
  mergeRanges(target[part], newSet[part]);
3931
4210
  else
@@ -3935,7 +4214,9 @@ function extendObservabilitySet(target, newSet) {
3935
4214
  }
3936
4215
 
3937
4216
  function obsSetsOverlap(os1, os2) {
3938
- return os1.all || os2.all || Object.keys(os1).some((key) => os2[key] && rangesOverlap(os2[key], os1[key]));
4217
+ return (os1.all ||
4218
+ os2.all ||
4219
+ Object.keys(os1).some((key) => os2[key] && rangesOverlap(os2[key], os1[key])));
3939
4220
  }
3940
4221
 
3941
4222
  const cache = {};
@@ -4000,9 +4281,7 @@ function dexieOpen(db) {
4000
4281
  const state = db._state;
4001
4282
  const { indexedDB } = db._deps;
4002
4283
  if (state.isBeingOpened || db.idbdb)
4003
- return state.dbReadyPromise.then(() => state.dbOpenError ?
4004
- rejection(state.dbOpenError) :
4005
- db);
4284
+ return state.dbReadyPromise.then(() => state.dbOpenError ? rejection(state.dbOpenError) : db);
4006
4285
  state.isBeingOpened = true;
4007
4286
  state.dbOpenError = null;
4008
4287
  state.openComplete = false;
@@ -4020,14 +4299,14 @@ function dexieOpen(db) {
4020
4299
  if (!indexedDB)
4021
4300
  throw new exceptions.MissingAPI();
4022
4301
  const dbName = db.name;
4023
- const req = state.autoSchema || !nativeVerToOpen ?
4024
- indexedDB.open(dbName) :
4025
- indexedDB.open(dbName, nativeVerToOpen);
4302
+ const req = state.autoSchema || !nativeVerToOpen
4303
+ ? indexedDB.open(dbName)
4304
+ : indexedDB.open(dbName, nativeVerToOpen);
4026
4305
  if (!req)
4027
4306
  throw new exceptions.MissingAPI();
4028
4307
  req.onerror = eventRejectHandler(reject);
4029
4308
  req.onblocked = wrap(db._fireOnBlocked);
4030
- req.onupgradeneeded = wrap(e => {
4309
+ req.onupgradeneeded = wrap((e) => {
4031
4310
  upgradeTransaction = req.transaction;
4032
4311
  if (state.autoSchema && !db._options.allowEmptyDB) {
4033
4312
  req.onerror = preventDefault;
@@ -4051,7 +4330,7 @@ function dexieOpen(db) {
4051
4330
  }, reject);
4052
4331
  req.onsuccess = wrap(() => {
4053
4332
  upgradeTransaction = null;
4054
- const idbdb = db.idbdb = req.result;
4333
+ const idbdb = (db.idbdb = req.result);
4055
4334
  const objectStoreNames = slice(idbdb.objectStoreNames);
4056
4335
  if (objectStoreNames.length > 0)
4057
4336
  try {
@@ -4073,9 +4352,9 @@ function dexieOpen(db) {
4073
4352
  catch (e) {
4074
4353
  }
4075
4354
  connections.add(db);
4076
- idbdb.onversionchange = wrap(ev => {
4355
+ idbdb.onversionchange = wrap((ev) => {
4077
4356
  state.vcFired = true;
4078
- db.on("versionchange").fire(ev);
4357
+ db.on('versionchange').fire(ev);
4079
4358
  });
4080
4359
  idbdb.onclose = wrap(() => {
4081
4360
  db.close({ disableAutoOpen: false });
@@ -4084,16 +4363,16 @@ function dexieOpen(db) {
4084
4363
  _onDatabaseCreated(db._deps, dbName);
4085
4364
  resolve();
4086
4365
  }, reject);
4087
- }).catch(err => {
4366
+ }).catch((err) => {
4088
4367
  switch (err?.name) {
4089
- case "UnknownError":
4368
+ case 'UnknownError':
4090
4369
  if (state.PR1398_maxLoop > 0) {
4091
4370
  state.PR1398_maxLoop--;
4092
4371
  console.warn('Dexie: Workaround for Chrome UnknownError on open()');
4093
4372
  return tryOpenDB();
4094
4373
  }
4095
4374
  break;
4096
- case "VersionError":
4375
+ case 'VersionError':
4097
4376
  if (nativeVerToOpen > 0) {
4098
4377
  nativeVerToOpen = 0;
4099
4378
  return tryOpenDB();
@@ -4104,8 +4383,11 @@ function dexieOpen(db) {
4104
4383
  });
4105
4384
  return DexiePromise.race([
4106
4385
  openCanceller,
4107
- (typeof navigator === 'undefined' ? DexiePromise.resolve() : idbReady()).then(tryOpenDB)
4108
- ]).then(() => {
4386
+ (typeof navigator === 'undefined'
4387
+ ? DexiePromise.resolve()
4388
+ : idbReady()).then(tryOpenDB),
4389
+ ])
4390
+ .then(() => {
4109
4391
  throwIfCancelled();
4110
4392
  state.onReadyBeingFired = [];
4111
4393
  return DexiePromise.resolve(vip(() => db.on.ready.fire(db.vip))).then(function fireRemainders() {
@@ -4115,12 +4397,14 @@ function dexieOpen(db) {
4115
4397
  return DexiePromise.resolve(vip(() => remainders(db.vip))).then(fireRemainders);
4116
4398
  }
4117
4399
  });
4118
- }).finally(() => {
4400
+ })
4401
+ .finally(() => {
4119
4402
  if (state.openCanceller === openCanceller) {
4120
4403
  state.onReadyBeingFired = null;
4121
4404
  state.isBeingOpened = false;
4122
4405
  }
4123
- }).catch(err => {
4406
+ })
4407
+ .catch((err) => {
4124
4408
  state.dbOpenError = err;
4125
4409
  try {
4126
4410
  upgradeTransaction && upgradeTransaction.abort();
@@ -4130,16 +4414,19 @@ function dexieOpen(db) {
4130
4414
  db._close();
4131
4415
  }
4132
4416
  return rejection(err);
4133
- }).finally(() => {
4417
+ })
4418
+ .finally(() => {
4134
4419
  state.openComplete = true;
4135
4420
  resolveDbReady();
4136
- }).then(() => {
4421
+ })
4422
+ .then(() => {
4137
4423
  if (wasCreated) {
4138
4424
  const everything = {};
4139
- db.tables.forEach(table => {
4140
- table.schema.indexes.forEach(idx => {
4425
+ db.tables.forEach((table) => {
4426
+ table.schema.indexes.forEach((idx) => {
4141
4427
  if (idx.name)
4142
- everything[`idb://${db.name}/${table.name}/${idx.name}`] = new RangeSet(-Infinity, [[[]]]);
4428
+ everything[`idb://${db.name}/${table.name}/${idx.name}`] =
4429
+ new RangeSet(-Infinity, [[[]]]);
4143
4430
  });
4144
4431
  everything[`idb://${db.name}/${table.name}/`] = everything[`idb://${db.name}/${table.name}/:dels`] = new RangeSet(-Infinity, [[[]]]);
4145
4432
  });
@@ -4151,14 +4438,17 @@ function dexieOpen(db) {
4151
4438
  }
4152
4439
 
4153
4440
  function awaitIterator(iterator) {
4154
- var callNext = result => iterator.next(result), doThrow = error => iterator.throw(error), onSuccess = step(callNext), onError = step(doThrow);
4441
+ var callNext = (result) => iterator.next(result), doThrow = (error) => iterator.throw(error), onSuccess = step(callNext), onError = step(doThrow);
4155
4442
  function step(getNext) {
4156
4443
  return (val) => {
4157
4444
  var next = getNext(val), value = next.value;
4158
- return next.done ? value :
4159
- (!value || typeof value.then !== 'function' ?
4160
- isArray(value) ? Promise.all(value).then(onSuccess, onError) : onSuccess(value) :
4161
- value.then(onSuccess, onError));
4445
+ return next.done
4446
+ ? value
4447
+ : !value || typeof value.then !== 'function'
4448
+ ? isArray(value)
4449
+ ? Promise.all(value).then(onSuccess, onError)
4450
+ : onSuccess(value)
4451
+ : value.then(onSuccess, onError);
4162
4452
  };
4163
4453
  }
4164
4454
  return step(callNext)();
@@ -4167,7 +4457,7 @@ function awaitIterator(iterator) {
4167
4457
  function extractTransactionArgs(mode, _tableArgs_, scopeFunc) {
4168
4458
  var i = arguments.length;
4169
4459
  if (i < 2)
4170
- throw new exceptions.InvalidArgument("Too few arguments");
4460
+ throw new exceptions.InvalidArgument('Too few arguments');
4171
4461
  var args = new Array(i - 1);
4172
4462
  while (--i)
4173
4463
  args[i - 1] = arguments[i];
@@ -4182,7 +4472,7 @@ function enterTransactionScope(db, mode, storeNames, parentTransaction, scopeFun
4182
4472
  trans.explicit = true;
4183
4473
  const zoneProps = {
4184
4474
  trans: trans,
4185
- transless: transless
4475
+ transless: transless,
4186
4476
  };
4187
4477
  if (parentTransaction) {
4188
4478
  trans.idbtrans = parentTransaction.idbtrans;
@@ -4194,10 +4484,14 @@ function enterTransactionScope(db, mode, storeNames, parentTransaction, scopeFun
4194
4484
  db._state.PR1398_maxLoop = 3;
4195
4485
  }
4196
4486
  catch (ex) {
4197
- if (ex.name === errnames.InvalidState && db.isOpen() && --db._state.PR1398_maxLoop > 0) {
4487
+ if (ex.name === errnames.InvalidState &&
4488
+ db.isOpen() &&
4489
+ --db._state.PR1398_maxLoop > 0) {
4198
4490
  console.warn('Dexie: Need to reopen db');
4199
4491
  db.close({ disableAutoOpen: false });
4200
- return db.open().then(() => enterTransactionScope(db, mode, storeNames, null, scopeFunc));
4492
+ return db
4493
+ .open()
4494
+ .then(() => enterTransactionScope(db, mode, storeNames, null, scopeFunc));
4201
4495
  }
4202
4496
  return rejection(ex);
4203
4497
  }
@@ -4214,20 +4508,25 @@ function enterTransactionScope(db, mode, storeNames, parentTransaction, scopeFun
4214
4508
  var decrementor = decrementExpectedAwaits.bind(null, null);
4215
4509
  returnValue.then(decrementor, decrementor);
4216
4510
  }
4217
- else if (typeof returnValue.next === 'function' && typeof returnValue.throw === 'function') {
4511
+ else if (typeof returnValue.next === 'function' &&
4512
+ typeof returnValue.throw === 'function') {
4218
4513
  returnValue = awaitIterator(returnValue);
4219
4514
  }
4220
4515
  }
4221
4516
  }, zoneProps);
4222
- return (returnValue && typeof returnValue.then === 'function' ?
4223
- DexiePromise.resolve(returnValue).then(x => trans.active ?
4224
- x
4225
- : rejection(new exceptions.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn")))
4226
- : promiseFollowed.then(() => returnValue)).then(x => {
4517
+ return (returnValue && typeof returnValue.then === 'function'
4518
+ ?
4519
+ DexiePromise.resolve(returnValue).then((x) => trans.active
4520
+ ? x
4521
+ : rejection(new exceptions.PrematureCommit('Transaction committed too early. See http://bit.ly/2kdckMn')))
4522
+ :
4523
+ promiseFollowed.then(() => returnValue))
4524
+ .then((x) => {
4227
4525
  if (parentTransaction)
4228
4526
  trans._resolve();
4229
4527
  return trans._completion.then(() => x);
4230
- }).catch(e => {
4528
+ })
4529
+ .catch((e) => {
4231
4530
  trans._reject(e);
4232
4531
  return rejection(e);
4233
4532
  });
@@ -4250,8 +4549,13 @@ function createVirtualIndexMiddleware(down) {
4250
4549
  const allVirtualIndexes = [];
4251
4550
  function addVirtualIndexes(keyPath, keyTail, lowLevelIndex) {
4252
4551
  const keyPathAlias = getKeyPathAlias(keyPath);
4253
- const indexList = (indexLookup[keyPathAlias] = indexLookup[keyPathAlias] || []);
4254
- const keyLength = keyPath == null ? 0 : typeof keyPath === 'string' ? 1 : keyPath.length;
4552
+ const indexList = (indexLookup[keyPathAlias] =
4553
+ indexLookup[keyPathAlias] || []);
4554
+ const keyLength = keyPath == null
4555
+ ? 0
4556
+ : typeof keyPath === 'string'
4557
+ ? 1
4558
+ : keyPath.length;
4255
4559
  const isVirtual = keyTail > 0;
4256
4560
  const virtualIndex = {
4257
4561
  ...lowLevelIndex,
@@ -4263,23 +4567,23 @@ function createVirtualIndexMiddleware(down) {
4263
4567
  keyTail,
4264
4568
  keyLength,
4265
4569
  extractKey: getKeyExtractor(keyPath),
4266
- unique: !isVirtual && lowLevelIndex.unique
4570
+ unique: !isVirtual && lowLevelIndex.unique,
4267
4571
  };
4268
4572
  indexList.push(virtualIndex);
4269
4573
  if (!virtualIndex.isPrimaryKey) {
4270
4574
  allVirtualIndexes.push(virtualIndex);
4271
4575
  }
4272
4576
  if (keyLength > 1) {
4273
- const virtualKeyPath = keyLength === 2 ?
4274
- keyPath[0] :
4275
- keyPath.slice(0, keyLength - 1);
4577
+ const virtualKeyPath = keyLength === 2
4578
+ ? keyPath[0]
4579
+ : keyPath.slice(0, keyLength - 1);
4276
4580
  addVirtualIndexes(virtualKeyPath, keyTail + 1, lowLevelIndex);
4277
4581
  }
4278
4582
  indexList.sort((a, b) => a.keyTail - b.keyTail);
4279
4583
  return virtualIndex;
4280
4584
  }
4281
4585
  const primaryKey = addVirtualIndexes(schema.primaryKey.keyPath, 0, schema.primaryKey);
4282
- indexLookup[":id"] = [primaryKey];
4586
+ indexLookup[':id'] = [primaryKey];
4283
4587
  for (const index of schema.indexes) {
4284
4588
  addVirtualIndexes(index.keyPath, 0, index);
4285
4589
  }
@@ -4289,24 +4593,26 @@ function createVirtualIndexMiddleware(down) {
4289
4593
  }
4290
4594
  function translateRange(range, keyTail) {
4291
4595
  return {
4292
- type: range.type === 1 ?
4293
- 2 :
4294
- range.type,
4596
+ type: range.type === 1
4597
+ ? 2
4598
+ : range.type,
4295
4599
  lower: pad(range.lower, range.lowerOpen ? down.MAX_KEY : down.MIN_KEY, keyTail),
4296
4600
  lowerOpen: true,
4297
4601
  upper: pad(range.upper, range.upperOpen ? down.MIN_KEY : down.MAX_KEY, keyTail),
4298
- upperOpen: true
4602
+ upperOpen: true,
4299
4603
  };
4300
4604
  }
4301
4605
  function translateRequest(req) {
4302
4606
  const index = req.query.index;
4303
- return index.isVirtual ? {
4304
- ...req,
4305
- query: {
4306
- index: index.lowLevelIndex,
4307
- range: translateRange(req.query.range, index.keyTail)
4607
+ return index.isVirtual
4608
+ ? {
4609
+ ...req,
4610
+ query: {
4611
+ index: index.lowLevelIndex,
4612
+ range: translateRange(req.query.range, index.keyTail),
4613
+ },
4308
4614
  }
4309
- } : req;
4615
+ : req;
4310
4616
  }
4311
4617
  const result = {
4312
4618
  ...table,
@@ -4314,7 +4620,7 @@ function createVirtualIndexMiddleware(down) {
4314
4620
  ...schema,
4315
4621
  primaryKey,
4316
4622
  indexes: allVirtualIndexes,
4317
- getIndexByKeyPath: findBestIndex
4623
+ getIndexByKeyPath: findBestIndex,
4318
4624
  },
4319
4625
  count(req) {
4320
4626
  return table.count(translateRequest(req));
@@ -4323,61 +4629,62 @@ function createVirtualIndexMiddleware(down) {
4323
4629
  return table.query(translateRequest(req));
4324
4630
  },
4325
4631
  openCursor(req) {
4326
- const { keyTail, isVirtual, keyLength } = req.query.index;
4632
+ const { keyTail, isVirtual, keyLength } = req.query
4633
+ .index;
4327
4634
  if (!isVirtual)
4328
4635
  return table.openCursor(req);
4329
4636
  function createVirtualCursor(cursor) {
4330
4637
  function _continue(key) {
4331
- key != null ?
4332
- cursor.continue(pad(key, req.reverse ? down.MAX_KEY : down.MIN_KEY, keyTail)) :
4333
- req.unique ?
4334
- cursor.continue(cursor.key.slice(0, keyLength)
4335
- .concat(req.reverse
4336
- ? down.MIN_KEY
4337
- : down.MAX_KEY, keyTail)) :
4338
- cursor.continue();
4638
+ key != null
4639
+ ? cursor.continue(pad(key, req.reverse ? down.MAX_KEY : down.MIN_KEY, keyTail))
4640
+ : req.unique
4641
+ ? cursor.continue(cursor.key
4642
+ .slice(0, keyLength)
4643
+ .concat(req.reverse ? down.MIN_KEY : down.MAX_KEY, keyTail))
4644
+ : cursor.continue();
4339
4645
  }
4340
4646
  const virtualCursor = Object.create(cursor, {
4341
4647
  continue: { value: _continue },
4342
4648
  continuePrimaryKey: {
4343
4649
  value(key, primaryKey) {
4344
4650
  cursor.continuePrimaryKey(pad(key, down.MAX_KEY, keyTail), primaryKey);
4345
- }
4651
+ },
4346
4652
  },
4347
4653
  primaryKey: {
4348
4654
  get() {
4349
4655
  return cursor.primaryKey;
4350
- }
4656
+ },
4351
4657
  },
4352
4658
  key: {
4353
4659
  get() {
4354
4660
  const key = cursor.key;
4355
- return keyLength === 1 ?
4356
- key[0] :
4357
- key.slice(0, keyLength);
4358
- }
4661
+ return keyLength === 1
4662
+ ? key[0]
4663
+ : key.slice(0, keyLength);
4664
+ },
4359
4665
  },
4360
4666
  value: {
4361
4667
  get() {
4362
4668
  return cursor.value;
4363
- }
4364
- }
4669
+ },
4670
+ },
4365
4671
  });
4366
4672
  return virtualCursor;
4367
4673
  }
4368
- return table.openCursor(translateRequest(req))
4369
- .then(cursor => cursor && createVirtualCursor(cursor));
4370
- }
4674
+ return table
4675
+ .openCursor(translateRequest(req))
4676
+ .then((cursor) => cursor && createVirtualCursor(cursor));
4677
+ },
4371
4678
  };
4372
4679
  return result;
4373
- }
4680
+ },
4374
4681
  };
4375
4682
  }
4376
4683
  const virtualIndexMiddleware = {
4377
- stack: "dbcore",
4378
- name: "VirtualIndexMiddleware",
4684
+ stack: 'dbcore',
4685
+ name: 'VirtualIndexMiddleware',
4379
4686
  level: 1,
4380
- create: createVirtualIndexMiddleware
4687
+ create: createVirtualIndexMiddleware,
4381
4688
  };
4382
4689
 
4383
4690
  function getObjectDiff(a, b, rv, prfx) {
@@ -4421,8 +4728,8 @@ function getEffectiveKeys(primaryKey, req) {
4421
4728
  }
4422
4729
 
4423
4730
  const hooksMiddleware = {
4424
- stack: "dbcore",
4425
- name: "HooksMiddleware",
4731
+ stack: 'dbcore',
4732
+ name: 'HooksMiddleware',
4426
4733
  level: 2,
4427
4734
  create: (downCore) => ({
4428
4735
  ...downCore,
@@ -4457,22 +4764,24 @@ const hooksMiddleware = {
4457
4764
  const dxTrans = PSD.trans;
4458
4765
  const keys = req.keys || getEffectiveKeys(primaryKey, req);
4459
4766
  if (!keys)
4460
- throw new Error("Keys missing");
4461
- req = req.type === 'add' || req.type === 'put' ?
4462
- { ...req, keys } :
4463
- { ...req };
4767
+ throw new Error('Keys missing');
4768
+ req =
4769
+ req.type === 'add' || req.type === 'put'
4770
+ ? { ...req, keys }
4771
+ : { ...req };
4464
4772
  if (req.type !== 'delete')
4465
4773
  req.values = [...req.values];
4466
4774
  if (req.keys)
4467
4775
  req.keys = [...req.keys];
4468
- return getExistingValues(downTable, req, keys).then(existingValues => {
4776
+ return getExistingValues(downTable, req, keys).then((existingValues) => {
4469
4777
  const contexts = keys.map((key, i) => {
4470
4778
  const existingValue = existingValues[i];
4471
4779
  const ctx = { onerror: null, onsuccess: null };
4472
4780
  if (req.type === 'delete') {
4473
4781
  deleting.fire.call(ctx, key, existingValue, dxTrans);
4474
4782
  }
4475
- else if (req.type === 'add' || existingValue === undefined) {
4783
+ else if (req.type === 'add' ||
4784
+ existingValue === undefined) {
4476
4785
  const generatedPrimaryKey = creating.fire.call(ctx, key, req.values[i], dxTrans);
4477
4786
  if (key == null && generatedPrimaryKey != null) {
4478
4787
  key = generatedPrimaryKey;
@@ -4487,9 +4796,10 @@ const hooksMiddleware = {
4487
4796
  const additionalChanges = updating.fire.call(ctx, objectDiff, key, existingValue, dxTrans);
4488
4797
  if (additionalChanges) {
4489
4798
  const requestedValue = req.values[i];
4490
- Object.keys(additionalChanges).forEach(keyPath => {
4799
+ Object.keys(additionalChanges).forEach((keyPath) => {
4491
4800
  if (hasOwn(requestedValue, keyPath)) {
4492
- requestedValue[keyPath] = additionalChanges[keyPath];
4801
+ requestedValue[keyPath] =
4802
+ additionalChanges[keyPath];
4493
4803
  }
4494
4804
  else {
4495
4805
  setByKeyPath(requestedValue, keyPath, additionalChanges[keyPath]);
@@ -4499,7 +4809,9 @@ const hooksMiddleware = {
4499
4809
  }
4500
4810
  return ctx;
4501
4811
  });
4502
- return downTable.mutate(req).then(({ failures, results, numFailures, lastResult }) => {
4812
+ return downTable
4813
+ .mutate(req)
4814
+ .then(({ failures, results, numFailures, lastResult }) => {
4503
4815
  for (let i = 0; i < keys.length; ++i) {
4504
4816
  const primKey = results ? results[i] : keys[i];
4505
4817
  const ctx = contexts[i];
@@ -4507,15 +4819,17 @@ const hooksMiddleware = {
4507
4819
  ctx.onerror && ctx.onerror(failures[i]);
4508
4820
  }
4509
4821
  else {
4510
- ctx.onsuccess && ctx.onsuccess(req.type === 'put' && existingValues[i] ?
4511
- req.values[i] :
4512
- primKey
4513
- );
4822
+ ctx.onsuccess &&
4823
+ ctx.onsuccess(req.type === 'put' && existingValues[i]
4824
+ ? req.values[i]
4825
+ : primKey
4826
+ );
4514
4827
  }
4515
4828
  }
4516
4829
  return { failures, results, numFailures, lastResult };
4517
- }).catch(error => {
4518
- contexts.forEach(ctx => ctx.onerror && ctx.onerror(error));
4830
+ })
4831
+ .catch((error) => {
4832
+ contexts.forEach((ctx) => ctx.onerror && ctx.onerror(error));
4519
4833
  return Promise.reject(error);
4520
4834
  });
4521
4835
  });
@@ -4524,30 +4838,52 @@ const hooksMiddleware = {
4524
4838
  return deleteNextChunk(req.trans, req.range, 10000);
4525
4839
  }
4526
4840
  function deleteNextChunk(trans, range, limit) {
4527
- return downTable.query({ trans, values: false, query: { index: primaryKey, range }, limit })
4841
+ return downTable
4842
+ .query({
4843
+ trans,
4844
+ values: false,
4845
+ query: { index: primaryKey, range },
4846
+ limit,
4847
+ })
4528
4848
  .then(({ result }) => {
4529
- return addPutOrDelete({ type: 'delete', keys: result, trans }).then(res => {
4849
+ return addPutOrDelete({
4850
+ type: 'delete',
4851
+ keys: result,
4852
+ trans,
4853
+ }).then((res) => {
4530
4854
  if (res.numFailures > 0)
4531
4855
  return Promise.reject(res.failures[0]);
4532
4856
  if (result.length < limit) {
4533
- return { failures: [], numFailures: 0, lastResult: undefined };
4857
+ return {
4858
+ failures: [],
4859
+ numFailures: 0,
4860
+ lastResult: undefined,
4861
+ };
4534
4862
  }
4535
4863
  else {
4536
- return deleteNextChunk(trans, { ...range, lower: result[result.length - 1], lowerOpen: true }, limit);
4864
+ return deleteNextChunk(trans, {
4865
+ ...range,
4866
+ lower: result[result.length - 1],
4867
+ lowerOpen: true,
4868
+ }, limit);
4537
4869
  }
4538
4870
  });
4539
4871
  });
4540
4872
  }
4541
- }
4873
+ },
4542
4874
  };
4543
4875
  return tableMiddleware;
4544
4876
  },
4545
- })
4877
+ }),
4546
4878
  };
4547
4879
  function getExistingValues(table, req, effectiveKeys) {
4548
- return req.type === "add"
4880
+ return req.type === 'add'
4549
4881
  ? Promise.resolve([])
4550
- : table.getMany({ trans: req.trans, keys: effectiveKeys, cache: "immutable" });
4882
+ : table.getMany({
4883
+ trans: req.trans,
4884
+ keys: effectiveKeys,
4885
+ cache: 'immutable',
4886
+ });
4551
4887
  }
4552
4888
 
4553
4889
  function getFromTransactionCache(keys, cache, clone) {
@@ -4570,7 +4906,7 @@ function getFromTransactionCache(keys, cache, clone) {
4570
4906
  }
4571
4907
  }
4572
4908
  const cacheExistingValuesMiddleware = {
4573
- stack: "dbcore",
4909
+ stack: 'dbcore',
4574
4910
  level: -1,
4575
4911
  create: (core) => {
4576
4912
  return {
@@ -4582,21 +4918,21 @@ const cacheExistingValuesMiddleware = {
4582
4918
  if (!req.cache) {
4583
4919
  return table.getMany(req);
4584
4920
  }
4585
- const cachedResult = getFromTransactionCache(req.keys, req.trans["_cache"], req.cache === "clone");
4921
+ const cachedResult = getFromTransactionCache(req.keys, req.trans['_cache'], req.cache === 'clone');
4586
4922
  if (cachedResult) {
4587
4923
  return DexiePromise.resolve(cachedResult);
4588
4924
  }
4589
4925
  return table.getMany(req).then((res) => {
4590
- req.trans["_cache"] = {
4926
+ req.trans['_cache'] = {
4591
4927
  keys: req.keys,
4592
- values: req.cache === "clone" ? deepClone(res) : res,
4928
+ values: req.cache === 'clone' ? deepClone(res) : res,
4593
4929
  };
4594
4930
  return res;
4595
4931
  });
4596
4932
  },
4597
4933
  mutate: (req) => {
4598
- if (req.type !== "add")
4599
- req.trans["_cache"] = null;
4934
+ if (req.type !== 'add')
4935
+ req.trans['_cache'] = null;
4600
4936
  return table.mutate(req);
4601
4937
  },
4602
4938
  };
@@ -4629,9 +4965,9 @@ function isCachableRequest(type, req) {
4629
4965
  }
4630
4966
 
4631
4967
  const observabilityMiddleware = {
4632
- stack: "dbcore",
4968
+ stack: 'dbcore',
4633
4969
  level: 0,
4634
- name: "Observability",
4970
+ name: 'Observability',
4635
4971
  create: (core) => {
4636
4972
  const dbName = core.schema.name;
4637
4973
  const FULL_RANGE = new RangeSet(core.MIN_KEY, core.MAX_KEY);
@@ -4648,7 +4984,9 @@ const observabilityMiddleware = {
4648
4984
  const { schema } = table;
4649
4985
  const { primaryKey, indexes } = schema;
4650
4986
  const { extractKey, outbound } = primaryKey;
4651
- const indexesWithAutoIncPK = primaryKey.autoIncrement && indexes.filter((index) => index.compound && index.keyPath.includes(primaryKey.keyPath));
4987
+ const indexesWithAutoIncPK = primaryKey.autoIncrement &&
4988
+ indexes.filter((index) => index.compound &&
4989
+ index.keyPath.includes(primaryKey.keyPath));
4652
4990
  const tableClone = {
4653
4991
  ...table,
4654
4992
  mutate: (req) => {
@@ -4659,20 +4997,25 @@ const observabilityMiddleware = {
4659
4997
  return (mutatedParts[part] ||
4660
4998
  (mutatedParts[part] = new RangeSet()));
4661
4999
  };
4662
- const pkRangeSet = getRangeSet("");
4663
- const delsRangeSet = getRangeSet(":dels");
5000
+ const pkRangeSet = getRangeSet('');
5001
+ const delsRangeSet = getRangeSet(':dels');
4664
5002
  const { type } = req;
4665
- let [keys, newObjs] = req.type === "deleteRange"
5003
+ let [keys, newObjs] = req.type === 'deleteRange'
4666
5004
  ? [req.range]
4667
- : req.type === "delete"
5005
+ : req.type === 'delete'
4668
5006
  ? [req.keys]
4669
5007
  : req.values.length < 50
4670
- ? [getEffectiveKeys(primaryKey, req).filter(id => id), req.values]
5008
+ ? [
5009
+ getEffectiveKeys(primaryKey, req).filter((id) => id),
5010
+ req.values,
5011
+ ]
4671
5012
  : [];
4672
- const oldCache = req.trans["_cache"];
5013
+ const oldCache = req.trans['_cache'];
4673
5014
  if (isArray(keys)) {
4674
5015
  pkRangeSet.addKeys(keys);
4675
- const oldObjs = type === 'delete' || keys.length === newObjs.length ? getFromTransactionCache(keys, oldCache) : null;
5016
+ const oldObjs = type === 'delete' || keys.length === newObjs.length
5017
+ ? getFromTransactionCache(keys, oldCache)
5018
+ : null;
4676
5019
  if (!oldObjs) {
4677
5020
  delsRangeSet.addKeys(keys);
4678
5021
  }
@@ -4683,7 +5026,7 @@ const observabilityMiddleware = {
4683
5026
  else if (keys) {
4684
5027
  const range = {
4685
5028
  from: keys.lower ?? core.MIN_KEY,
4686
- to: keys.upper ?? core.MAX_KEY
5029
+ to: keys.upper ?? core.MAX_KEY,
4687
5030
  };
4688
5031
  delsRangeSet.add(range);
4689
5032
  pkRangeSet.add(range);
@@ -4691,15 +5034,15 @@ const observabilityMiddleware = {
4691
5034
  else {
4692
5035
  pkRangeSet.add(FULL_RANGE);
4693
5036
  delsRangeSet.add(FULL_RANGE);
4694
- schema.indexes.forEach(idx => getRangeSet(idx.name).add(FULL_RANGE));
5037
+ schema.indexes.forEach((idx) => getRangeSet(idx.name).add(FULL_RANGE));
4695
5038
  }
4696
5039
  return table.mutate(req).then((res) => {
4697
5040
  if (keys && (req.type === 'add' || req.type === 'put')) {
4698
5041
  pkRangeSet.addKeys(res.results);
4699
5042
  if (indexesWithAutoIncPK) {
4700
- indexesWithAutoIncPK.forEach(idx => {
4701
- const idxVals = req.values.map(v => idx.extractKey(v));
4702
- const pkPos = idx.keyPath.findIndex(prop => prop === primaryKey.keyPath);
5043
+ indexesWithAutoIncPK.forEach((idx) => {
5044
+ const idxVals = req.values.map((v) => idx.extractKey(v));
5045
+ const pkPos = idx.keyPath.findIndex((prop) => prop === primaryKey.keyPath);
4703
5046
  for (let i = 0, len = res.results.length; i < len; ++i) {
4704
5047
  idxVals[i][pkPos] = res.results[i];
4705
5048
  }
@@ -4727,9 +5070,10 @@ const observabilityMiddleware = {
4727
5070
  tableClone[method] = function (req) {
4728
5071
  const { subscr } = PSD;
4729
5072
  const isLiveQuery = !!subscr;
4730
- let cachable = isCachableContext(PSD, table) && isCachableRequest(method, req);
5073
+ let cachable = isCachableContext(PSD, table) &&
5074
+ isCachableRequest(method, req);
4731
5075
  const obsSet = cachable
4732
- ? req.obsSet = {}
5076
+ ? (req.obsSet = {})
4733
5077
  : subscr;
4734
5078
  if (isLiveQuery) {
4735
5079
  const getRangeSet = (indexName) => {
@@ -4737,21 +5081,23 @@ const observabilityMiddleware = {
4737
5081
  return (obsSet[part] ||
4738
5082
  (obsSet[part] = new RangeSet()));
4739
5083
  };
4740
- const pkRangeSet = getRangeSet("");
4741
- const delsRangeSet = getRangeSet(":dels");
5084
+ const pkRangeSet = getRangeSet('');
5085
+ const delsRangeSet = getRangeSet(':dels');
4742
5086
  const [queriedIndex, queriedRanges] = readSubscribers[method](req);
4743
- if (method === 'query' && queriedIndex.isPrimaryKey && !req.values) {
5087
+ if (method === 'query' &&
5088
+ queriedIndex.isPrimaryKey &&
5089
+ !req.values) {
4744
5090
  delsRangeSet.add(queriedRanges);
4745
5091
  }
4746
5092
  else {
4747
- getRangeSet(queriedIndex.name || "").add(queriedRanges);
5093
+ getRangeSet(queriedIndex.name || '').add(queriedRanges);
4748
5094
  }
4749
5095
  if (!queriedIndex.isPrimaryKey) {
4750
- if (method === "count") {
5096
+ if (method === 'count') {
4751
5097
  delsRangeSet.add(FULL_RANGE);
4752
5098
  }
4753
5099
  else {
4754
- const keysPromise = method === "query" &&
5100
+ const keysPromise = method === 'query' &&
4755
5101
  outbound &&
4756
5102
  req.values &&
4757
5103
  table.query({
@@ -4759,9 +5105,9 @@ const observabilityMiddleware = {
4759
5105
  values: false,
4760
5106
  });
4761
5107
  return table[method].apply(this, arguments).then((res) => {
4762
- if (method === "query") {
5108
+ if (method === 'query') {
4763
5109
  if (outbound && req.values) {
4764
- return keysPromise.then(({ result: resultingKeys }) => {
5110
+ return keysPromise.then(({ result: resultingKeys, }) => {
4765
5111
  pkRangeSet.addKeys(resultingKeys);
4766
5112
  return res;
4767
5113
  });
@@ -4776,9 +5122,10 @@ const observabilityMiddleware = {
4776
5122
  delsRangeSet.addKeys(pKeys);
4777
5123
  }
4778
5124
  }
4779
- else if (method === "openCursor") {
5125
+ else if (method === 'openCursor') {
4780
5126
  const cursor = res;
4781
- const wantValues = req.values;
5127
+ const wantValues = req
5128
+ .values;
4782
5129
  return (cursor &&
4783
5130
  Object.create(cursor, {
4784
5131
  key: {
@@ -4796,7 +5143,8 @@ const observabilityMiddleware = {
4796
5143
  },
4797
5144
  value: {
4798
5145
  get() {
4799
- wantValues && pkRangeSet.addKey(cursor.primaryKey);
5146
+ wantValues &&
5147
+ pkRangeSet.addKey(cursor.primaryKey);
4800
5148
  return cursor.value;
4801
5149
  },
4802
5150
  },
@@ -4817,13 +5165,15 @@ const observabilityMiddleware = {
4817
5165
  };
4818
5166
  function trackAffectedIndexes(getRangeSet, schema, oldObjs, newObjs) {
4819
5167
  function addAffectedIndex(ix) {
4820
- const rangeSet = getRangeSet(ix.name || "");
5168
+ const rangeSet = getRangeSet(ix.name || '');
4821
5169
  function extractKey(obj) {
4822
5170
  return obj != null ? ix.extractKey(obj) : null;
4823
5171
  }
4824
5172
  const addKeyOrKeys = (key) => ix.multiEntry && isArray(key)
4825
- ? key.forEach(key => rangeSet.addKey(key))
4826
- : rangeSet.addKey(key);
5173
+ ?
5174
+ key.forEach((key) => rangeSet.addKey(key))
5175
+ :
5176
+ rangeSet.addKey(key);
4827
5177
  (oldObjs || newObjs).forEach((_, i) => {
4828
5178
  const oldKey = oldObjs && extractKey(oldObjs[i]);
4829
5179
  const newKey = newObjs && extractKey(newObjs[i]);
@@ -5030,7 +5380,8 @@ function findCompatibleQuery(dbName, tableName, type, req) {
5030
5380
  const reqDirection = req.direction ?? 'next';
5031
5381
  const equalEntry = entries.find((entry) => entry.req.limit === req.limit &&
5032
5382
  entry.req.values === req.values &&
5033
- (entry.req.direction ?? 'next') === reqDirection &&
5383
+ (entry.req.direction ?? 'next') ===
5384
+ reqDirection &&
5034
5385
  areRangesEqual(entry.req.query.range, req.query.range));
5035
5386
  if (equalEntry)
5036
5387
  return [
@@ -5042,7 +5393,8 @@ function findCompatibleQuery(dbName, tableName, type, req) {
5042
5393
  const superEntry = entries.find((entry) => {
5043
5394
  const limit = 'limit' in entry.req ? entry.req.limit : Infinity;
5044
5395
  return (limit >= req.limit &&
5045
- (entry.req.direction ?? 'next') === reqDirection &&
5396
+ (entry.req.direction ?? 'next') ===
5397
+ reqDirection &&
5046
5398
  (req.values ? entry.req.values : true) &&
5047
5399
  isSuperRange(entry.req.query.range, req.query.range));
5048
5400
  });
@@ -5055,7 +5407,7 @@ function findCompatibleQuery(dbName, tableName, type, req) {
5055
5407
 
5056
5408
  function subscribeToCacheEntry(cacheEntry, container, requery, signal) {
5057
5409
  cacheEntry.subscribers.add(requery);
5058
- signal.addEventListener("abort", () => {
5410
+ signal.addEventListener('abort', () => {
5059
5411
  cacheEntry.subscribers.delete(requery);
5060
5412
  if (cacheEntry.subscribers.size === 0) {
5061
5413
  enqueForDeletion(cacheEntry, container);
@@ -5092,7 +5444,9 @@ const cacheMiddleware = {
5092
5444
  if (tblCache) {
5093
5445
  const table = core.table(storeName);
5094
5446
  const ops = tblCache.optimisticOps.filter((op) => op.trans === idbtrans);
5095
- if (idbtrans._explicit && wasCommitted && idbtrans.mutatedParts) {
5447
+ if (idbtrans._explicit &&
5448
+ wasCommitted &&
5449
+ idbtrans.mutatedParts) {
5096
5450
  for (const entries of Object.values(tblCache.queries.query)) {
5097
5451
  for (const entry of entries.slice()) {
5098
5452
  if (obsSetsOverlap(entry.obsSet, idbtrans.mutatedParts)) {
@@ -5118,7 +5472,9 @@ const cacheMiddleware = {
5118
5472
  }
5119
5473
  else if (modRes !== entry.res) {
5120
5474
  entry.res = modRes;
5121
- entry.promise = DexiePromise.resolve({ result: modRes });
5475
+ entry.promise = DexiePromise.resolve({
5476
+ result: modRes,
5477
+ });
5122
5478
  }
5123
5479
  }
5124
5480
  else {
@@ -5166,7 +5522,9 @@ const cacheMiddleware = {
5166
5522
  if (!tblCache)
5167
5523
  return downTable.mutate(req);
5168
5524
  const promise = downTable.mutate(req);
5169
- if ((req.type === 'add' || req.type === 'put') && (req.values.length >= 50 || getEffectiveKeys(primKey, req).some(key => key == null))) {
5525
+ if ((req.type === 'add' || req.type === 'put') &&
5526
+ (req.values.length >= 50 ||
5527
+ getEffectiveKeys(primKey, req).some((key) => key == null))) {
5170
5528
  promise.then((res) => {
5171
5529
  const reqWithResolvedKeys = {
5172
5530
  ...req,
@@ -5180,11 +5538,12 @@ const cacheMiddleware = {
5180
5538
  };
5181
5539
  setByKeyPath(valueWithKey, primKey.keyPath, res.results[i]);
5182
5540
  return valueWithKey;
5183
- })
5541
+ }),
5184
5542
  };
5185
5543
  const adjustedReq = adjustOptimisticFromFailures(tblCache, reqWithResolvedKeys, res);
5186
5544
  tblCache.optimisticOps.push(adjustedReq);
5187
- queueMicrotask(() => req.mutatedParts && signalSubscribersLazily(req.mutatedParts));
5545
+ queueMicrotask(() => req.mutatedParts &&
5546
+ signalSubscribersLazily(req.mutatedParts));
5188
5547
  });
5189
5548
  }
5190
5549
  else {
@@ -5208,16 +5567,20 @@ const cacheMiddleware = {
5208
5567
  return promise;
5209
5568
  },
5210
5569
  query(req) {
5211
- if (!isCachableContext(PSD, downTable) || !isCachableRequest("query", req))
5570
+ if (!isCachableContext(PSD, downTable) ||
5571
+ !isCachableRequest('query', req))
5212
5572
  return downTable.query(req);
5213
- const freezeResults = PSD.trans?.db._options.cache === 'immutable';
5573
+ const freezeResults = PSD.trans?.db._options.cache ===
5574
+ 'immutable';
5214
5575
  const { requery, signal } = PSD;
5215
5576
  let [cacheEntry, exactMatch, tblCache, container] = findCompatibleQuery(dbName, tableName, 'query', req);
5216
5577
  if (cacheEntry && exactMatch) {
5217
5578
  cacheEntry.obsSet = req.obsSet;
5218
5579
  }
5219
5580
  else {
5220
- const promise = downTable.query(req).then((res) => {
5581
+ const promise = downTable
5582
+ .query(req)
5583
+ .then((res) => {
5221
5584
  const result = res.result;
5222
5585
  if (cacheEntry)
5223
5586
  cacheEntry.res = result;
@@ -5231,7 +5594,8 @@ const cacheMiddleware = {
5231
5594
  res.result = deepClone(result);
5232
5595
  }
5233
5596
  return res;
5234
- }).catch(error => {
5597
+ })
5598
+ .catch((error) => {
5235
5599
  if (container && cacheEntry)
5236
5600
  delArrayItem(container, cacheEntry);
5237
5601
  return Promise.reject(error);
@@ -5257,7 +5621,7 @@ const cacheMiddleware = {
5257
5621
  },
5258
5622
  objs: new Map(),
5259
5623
  optimisticOps: [],
5260
- unsignaledParts: {}
5624
+ unsignaledParts: {},
5261
5625
  };
5262
5626
  }
5263
5627
  tblCache.queries.query[req.query.index.name || ''] = container;
@@ -5284,7 +5648,7 @@ function vipify(target, vipDb) {
5284
5648
  if (prop === 'db')
5285
5649
  return vipDb;
5286
5650
  return Reflect.get(target, prop, receiver);
5287
- }
5651
+ },
5288
5652
  });
5289
5653
  }
5290
5654
 
@@ -5300,13 +5664,13 @@ let Dexie$1 = class Dexie {
5300
5664
  IDBKeyRange: deps.IDBKeyRange,
5301
5665
  cache: 'cloned',
5302
5666
  maxConnections: DEFAULT_MAX_CONNECTIONS,
5303
- ...options
5667
+ ...options,
5304
5668
  };
5305
5669
  this._deps = {
5306
5670
  indexedDB: options.indexedDB,
5307
- IDBKeyRange: options.IDBKeyRange
5671
+ IDBKeyRange: options.IDBKeyRange,
5308
5672
  };
5309
- const { addons, } = options;
5673
+ const { addons } = options;
5310
5674
  this._dbSchema = {};
5311
5675
  this._versions = [];
5312
5676
  this._storeNames = [];
@@ -5326,7 +5690,7 @@ let Dexie$1 = class Dexie {
5326
5690
  PR1398_maxLoop: 3,
5327
5691
  autoOpen: options.autoOpen,
5328
5692
  };
5329
- state.dbReadyPromise = new DexiePromise(resolve => {
5693
+ state.dbReadyPromise = new DexiePromise((resolve) => {
5330
5694
  state.dbReadyResolve = resolve;
5331
5695
  });
5332
5696
  state.openCanceller = new DexiePromise((_, reject) => {
@@ -5334,7 +5698,9 @@ let Dexie$1 = class Dexie {
5334
5698
  });
5335
5699
  this._state = state;
5336
5700
  this.name = name;
5337
- this.on = Events(this, "populate", "blocked", "versionchange", "close", { ready: [promisableChain, nop] });
5701
+ this.on = Events(this, 'populate', 'blocked', 'versionchange', 'close', {
5702
+ ready: [promisableChain, nop],
5703
+ });
5338
5704
  this.once = (event, callback) => {
5339
5705
  const fn = (...args) => {
5340
5706
  this.on(event).unsubscribe(fn);
@@ -5342,7 +5708,7 @@ let Dexie$1 = class Dexie {
5342
5708
  };
5343
5709
  return this.on(event, fn);
5344
5710
  };
5345
- this.on.ready.subscribe = override(this.on.ready.subscribe, subscribe => {
5711
+ this.on.ready.subscribe = override(this.on.ready.subscribe, (subscribe) => {
5346
5712
  return (subscriber, bSticky) => {
5347
5713
  Dexie.vip(() => {
5348
5714
  const state = this._state;
@@ -5374,14 +5740,14 @@ let Dexie$1 = class Dexie {
5374
5740
  this.Transaction = createTransactionConstructor(this);
5375
5741
  this.Version = createVersionConstructor(this);
5376
5742
  this.WhereClause = createWhereClauseConstructor(this);
5377
- this.on("versionchange", ev => {
5743
+ this.on('versionchange', (ev) => {
5378
5744
  if (ev.newVersion > 0)
5379
5745
  console.warn(`Another connection wants to upgrade database '${this.name}'. Closing db now to resume the upgrade.`);
5380
5746
  else
5381
5747
  console.warn(`Another connection wants to delete database '${this.name}'. Closing db now to resume the delete request.`);
5382
5748
  this.close({ disableAutoOpen: false });
5383
5749
  });
5384
- this.on("blocked", ev => {
5750
+ this.on('blocked', (ev) => {
5385
5751
  if (!ev.newVersion || ev.newVersion < ev.oldVersion)
5386
5752
  console.warn(`Dexie.delete('${this.name}') was blocked`);
5387
5753
  else
@@ -5389,11 +5755,12 @@ let Dexie$1 = class Dexie {
5389
5755
  });
5390
5756
  this._maxKey = getMaxKey(options.IDBKeyRange);
5391
5757
  this._createTransaction = (mode, storeNames, dbschema, parentTransaction) => new this.Transaction(mode, storeNames, dbschema, this._options.chromeTransactionDurability, parentTransaction);
5392
- this._fireOnBlocked = ev => {
5393
- this.on("blocked").fire(ev);
5394
- connections.toArray()
5395
- .filter(c => c.name === this.name && c !== this && !c._state.vcFired)
5396
- .map(c => c.on("versionchange").fire(ev));
5758
+ this._fireOnBlocked = (ev) => {
5759
+ this.on('blocked').fire(ev);
5760
+ connections
5761
+ .toArray()
5762
+ .filter((c) => c.name === this.name && c !== this && !c._state.vcFired)
5763
+ .map((c) => c.on('versionchange').fire(ev));
5397
5764
  };
5398
5765
  this.use(cacheExistingValuesMiddleware);
5399
5766
  this.use(cacheMiddleware);
@@ -5410,27 +5777,27 @@ let Dexie$1 = class Dexie {
5410
5777
  if (rv instanceof Table)
5411
5778
  return vipify(rv, vipDB);
5412
5779
  if (prop === 'tables')
5413
- return rv.map(t => vipify(t, vipDB));
5780
+ return rv.map((t) => vipify(t, vipDB));
5414
5781
  if (prop === '_createTransaction')
5415
5782
  return function () {
5416
5783
  const tx = rv.apply(this, arguments);
5417
5784
  return vipify(tx, vipDB);
5418
5785
  };
5419
5786
  return rv;
5420
- }
5787
+ },
5421
5788
  });
5422
5789
  this.vip = vipDB;
5423
- addons.forEach(addon => addon(this));
5790
+ addons.forEach((addon) => addon(this));
5424
5791
  }
5425
5792
  version(versionNumber) {
5426
5793
  if (isNaN(versionNumber) || versionNumber < 0.1)
5427
5794
  throw new exceptions.Type(`Given version is not a positive number`);
5428
5795
  versionNumber = Math.round(versionNumber * 10) / 10;
5429
5796
  if (this.idbdb || this._state.isBeingOpened)
5430
- throw new exceptions.Schema("Cannot add version when database is open");
5797
+ throw new exceptions.Schema('Cannot add version when database is open');
5431
5798
  this.verno = Math.max(this.verno, versionNumber);
5432
5799
  const versions = this._versions;
5433
- var versionInstance = versions.filter(v => v._cfg.version === versionNumber)[0];
5800
+ var versionInstance = versions.filter((v) => v._cfg.version === versionNumber)[0];
5434
5801
  if (versionInstance)
5435
5802
  return versionInstance;
5436
5803
  versionInstance = new this.Version(versionNumber);
@@ -5441,33 +5808,43 @@ let Dexie$1 = class Dexie {
5441
5808
  return versionInstance;
5442
5809
  }
5443
5810
  _whenReady(fn) {
5444
- return (this.idbdb && (this._state.openComplete || PSD.letThrough || this._vip)) ? fn() : new DexiePromise((resolve, reject) => {
5445
- if (this._state.openComplete) {
5446
- return reject(new exceptions.DatabaseClosed(this._state.dbOpenError));
5447
- }
5448
- if (!this._state.isBeingOpened) {
5449
- if (!this._state.autoOpen) {
5450
- reject(new exceptions.DatabaseClosed());
5451
- return;
5811
+ return this.idbdb &&
5812
+ (this._state.openComplete || PSD.letThrough || this._vip)
5813
+ ? fn()
5814
+ : new DexiePromise((resolve, reject) => {
5815
+ if (this._state.openComplete) {
5816
+ return reject(new exceptions.DatabaseClosed(this._state.dbOpenError));
5452
5817
  }
5453
- this.open().catch(nop);
5454
- }
5455
- this._state.dbReadyPromise.then(resolve, reject);
5456
- }).then(fn);
5818
+ if (!this._state.isBeingOpened) {
5819
+ if (!this._state.autoOpen) {
5820
+ reject(new exceptions.DatabaseClosed());
5821
+ return;
5822
+ }
5823
+ this.open().catch(nop);
5824
+ }
5825
+ this._state.dbReadyPromise.then(resolve, reject);
5826
+ }).then(fn);
5457
5827
  }
5458
5828
  use({ stack, create, level, name }) {
5459
5829
  if (name)
5460
5830
  this.unuse({ stack, name });
5461
5831
  const middlewares = this._middlewares[stack] || (this._middlewares[stack] = []);
5462
- middlewares.push({ stack, create, level: level == null ? 10 : level, name });
5832
+ middlewares.push({
5833
+ stack,
5834
+ create,
5835
+ level: level == null ? 10 : level,
5836
+ name,
5837
+ });
5463
5838
  middlewares.sort((a, b) => a.level - b.level);
5464
5839
  return this;
5465
5840
  }
5466
- unuse({ stack, name, create }) {
5841
+ unuse({ stack, name, create, }) {
5467
5842
  if (stack && this._middlewares[stack]) {
5468
- this._middlewares[stack] = this._middlewares[stack].filter(mw => create ? mw.create !== create :
5469
- name ? mw.name !== name :
5470
- false);
5843
+ this._middlewares[stack] = this._middlewares[stack].filter((mw) => create
5844
+ ? mw.create !== create
5845
+ : name
5846
+ ? mw.name !== name
5847
+ : false);
5471
5848
  }
5472
5849
  return this;
5473
5850
  }
@@ -5487,7 +5864,7 @@ let Dexie$1 = class Dexie {
5487
5864
  this.idbdb = null;
5488
5865
  }
5489
5866
  if (!state.isBeingOpened) {
5490
- state.dbReadyPromise = new DexiePromise(resolve => {
5867
+ state.dbReadyPromise = new DexiePromise((resolve) => {
5491
5868
  state.dbReadyResolve = resolve;
5492
5869
  });
5493
5870
  state.openCanceller = new DexiePromise((_, reject) => {
@@ -5507,8 +5884,7 @@ let Dexie$1 = class Dexie {
5507
5884
  }
5508
5885
  else {
5509
5886
  this._close();
5510
- state.autoOpen = this._options.autoOpen ||
5511
- state.isBeingOpened;
5887
+ state.autoOpen = this._options.autoOpen || state.isBeingOpened;
5512
5888
  state.openComplete = false;
5513
5889
  state.dbOpenError = null;
5514
5890
  }
@@ -5528,7 +5904,7 @@ let Dexie$1 = class Dexie {
5528
5904
  req.onblocked = this._fireOnBlocked;
5529
5905
  };
5530
5906
  if (hasInvalidArguments)
5531
- throw new exceptions.InvalidArgument("Invalid closeOptions argument to db.delete()");
5907
+ throw new exceptions.InvalidArgument('Invalid closeOptions argument to db.delete()');
5532
5908
  if (state.isBeingOpened) {
5533
5909
  state.dbReadyPromise.then(doDelete);
5534
5910
  }
@@ -5545,7 +5921,7 @@ let Dexie$1 = class Dexie {
5545
5921
  }
5546
5922
  hasBeenClosed() {
5547
5923
  const dbOpenError = this._state.dbOpenError;
5548
- return dbOpenError && (dbOpenError.name === 'DatabaseClosed');
5924
+ return dbOpenError && dbOpenError.name === 'DatabaseClosed';
5549
5925
  }
5550
5926
  hasFailed() {
5551
5927
  return this._state.dbOpenError !== null;
@@ -5554,7 +5930,7 @@ let Dexie$1 = class Dexie {
5554
5930
  return this._state.autoSchema;
5555
5931
  }
5556
5932
  get tables() {
5557
- return keys(this._allTables).map(name => this._allTables[name]);
5933
+ return keys(this._allTables).map((name) => this._allTables[name]);
5558
5934
  }
5559
5935
  transaction() {
5560
5936
  const args = extractTransactionArgs.apply(this, arguments);
@@ -5562,60 +5938,67 @@ let Dexie$1 = class Dexie {
5562
5938
  }
5563
5939
  _transaction(mode, tables, scopeFunc) {
5564
5940
  let parentTransaction = PSD.trans;
5565
- if (!parentTransaction || parentTransaction.db !== this || mode.indexOf('!') !== -1)
5941
+ if (!parentTransaction ||
5942
+ parentTransaction.db !== this ||
5943
+ mode.indexOf('!') !== -1)
5566
5944
  parentTransaction = null;
5567
5945
  const onlyIfCompatible = mode.indexOf('?') !== -1;
5568
5946
  mode = mode.replace('!', '').replace('?', '');
5569
5947
  let idbMode, storeNames;
5570
5948
  try {
5571
- storeNames = tables.map(table => {
5949
+ storeNames = tables.map((table) => {
5572
5950
  var storeName = table instanceof this.Table ? table.name : table;
5573
5951
  if (typeof storeName !== 'string')
5574
- throw new TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");
5952
+ throw new TypeError('Invalid table argument to Dexie.transaction(). Only Table or String are allowed');
5575
5953
  return storeName;
5576
5954
  });
5577
- if (mode == "r" || mode === READONLY)
5955
+ if (mode == 'r' || mode === READONLY)
5578
5956
  idbMode = READONLY;
5579
- else if (mode == "rw" || mode == READWRITE)
5957
+ else if (mode == 'rw' || mode == READWRITE)
5580
5958
  idbMode = READWRITE;
5581
5959
  else
5582
- throw new exceptions.InvalidArgument("Invalid transaction mode: " + mode);
5960
+ throw new exceptions.InvalidArgument('Invalid transaction mode: ' + mode);
5583
5961
  if (parentTransaction) {
5584
5962
  if (parentTransaction.mode === READONLY && idbMode === READWRITE) {
5585
5963
  if (onlyIfCompatible) {
5586
5964
  parentTransaction = null;
5587
5965
  }
5588
5966
  else
5589
- throw new exceptions.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");
5967
+ throw new exceptions.SubTransaction('Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY');
5590
5968
  }
5591
5969
  if (parentTransaction) {
5592
- storeNames.forEach(storeName => {
5593
- if (parentTransaction && parentTransaction.storeNames.indexOf(storeName) === -1) {
5970
+ storeNames.forEach((storeName) => {
5971
+ if (parentTransaction &&
5972
+ parentTransaction.storeNames.indexOf(storeName) === -1) {
5594
5973
  if (onlyIfCompatible) {
5595
5974
  parentTransaction = null;
5596
5975
  }
5597
5976
  else
5598
- throw new exceptions.SubTransaction("Table " + storeName +
5599
- " not included in parent transaction.");
5977
+ throw new exceptions.SubTransaction('Table ' + storeName + ' not included in parent transaction.');
5600
5978
  }
5601
5979
  });
5602
5980
  }
5603
- if (onlyIfCompatible && parentTransaction && !parentTransaction.active) {
5981
+ if (onlyIfCompatible &&
5982
+ parentTransaction &&
5983
+ !parentTransaction.active) {
5604
5984
  parentTransaction = null;
5605
5985
  }
5606
5986
  }
5607
5987
  }
5608
5988
  catch (e) {
5609
- return parentTransaction ?
5610
- parentTransaction._promise(null, (_, reject) => { reject(e); }) :
5611
- rejection(e);
5989
+ return parentTransaction
5990
+ ? parentTransaction._promise(null, (_, reject) => {
5991
+ reject(e);
5992
+ })
5993
+ : rejection(e);
5612
5994
  }
5613
5995
  const enterTransaction = enterTransactionScope.bind(null, this, idbMode, storeNames, parentTransaction, scopeFunc);
5614
- return (parentTransaction ?
5615
- parentTransaction._promise(idbMode, enterTransaction, "lock") :
5616
- PSD.trans ?
5617
- usePSD(PSD.transless, () => this._whenReady(enterTransaction)) :
5618
- this._whenReady(enterTransaction));
5996
+ return parentTransaction
5997
+ ? parentTransaction._promise(idbMode, enterTransaction, 'lock')
5998
+ : PSD.trans
5999
+ ?
6000
+ usePSD(PSD.transless, () => this._whenReady(enterTransaction))
6001
+ : this._whenReady(enterTransaction);
5619
6002
  }
5620
6003
  table(tableName) {
5621
6004
  if (!hasOwn(this._allTables, tableName)) {
@@ -5625,15 +6008,15 @@ let Dexie$1 = class Dexie {
5625
6008
  }
5626
6009
  };
5627
6010
 
5628
- const symbolObservable = typeof Symbol !== "undefined" && "observable" in Symbol
6011
+ const symbolObservable = typeof Symbol !== 'undefined' && 'observable' in Symbol
5629
6012
  ? Symbol.observable
5630
- : "@@observable";
6013
+ : '@@observable';
5631
6014
  class Observable {
5632
6015
  constructor(subscribe) {
5633
6016
  this._subscribe = subscribe;
5634
6017
  }
5635
6018
  subscribe(x, error, complete) {
5636
- return this._subscribe(!x || typeof x === "function" ? { next: x, error, complete } : x);
6019
+ return this._subscribe(!x || typeof x === 'function' ? { next: x, error, complete } : x);
5637
6020
  }
5638
6021
  [symbolObservable]() {
5639
6022
  return this;
@@ -5643,8 +6026,11 @@ class Observable {
5643
6026
  let domDeps;
5644
6027
  try {
5645
6028
  domDeps = {
5646
- indexedDB: _global.indexedDB || _global.mozIndexedDB || _global.webkitIndexedDB || _global.msIndexedDB,
5647
- IDBKeyRange: _global.IDBKeyRange || _global.webkitIDBKeyRange
6029
+ indexedDB: _global.indexedDB ||
6030
+ _global.mozIndexedDB ||
6031
+ _global.webkitIndexedDB ||
6032
+ _global.msIndexedDB,
6033
+ IDBKeyRange: _global.IDBKeyRange || _global.webkitIDBKeyRange,
5648
6034
  };
5649
6035
  }
5650
6036
  catch (e) {
@@ -5772,10 +6158,13 @@ props(Dexie, {
5772
6158
  return db.delete();
5773
6159
  },
5774
6160
  exists(name) {
5775
- return new Dexie(name, { addons: [] }).open().then(db => {
6161
+ return new Dexie(name, { addons: [] })
6162
+ .open()
6163
+ .then((db) => {
5776
6164
  db.close();
5777
6165
  return true;
5778
- }).catch('NoSuchDatabaseError', () => false);
6166
+ })
6167
+ .catch('NoSuchDatabaseError', () => false);
5779
6168
  },
5780
6169
  getDatabaseNames(cb) {
5781
6170
  try {
@@ -5792,9 +6181,9 @@ props(Dexie, {
5792
6181
  return Class;
5793
6182
  },
5794
6183
  ignoreTransaction(scopeFunc) {
5795
- return PSD.trans ?
5796
- usePSD(PSD.transless, scopeFunc) :
5797
- scopeFunc();
6184
+ return PSD.trans
6185
+ ? usePSD(PSD.transless || globalPSD, scopeFunc)
6186
+ : scopeFunc();
5798
6187
  },
5799
6188
  vip,
5800
6189
  async: function (generatorFn) {
@@ -5822,23 +6211,20 @@ props(Dexie, {
5822
6211
  }
5823
6212
  },
5824
6213
  currentTransaction: {
5825
- get: () => PSD.trans || null
6214
+ get: () => PSD.trans || null,
5826
6215
  },
5827
6216
  waitFor: function (promiseOrFunction, optionalTimeout) {
5828
- const promise = DexiePromise.resolve(typeof promiseOrFunction === 'function' ?
5829
- Dexie.ignoreTransaction(promiseOrFunction) :
5830
- promiseOrFunction)
5831
- .timeout(optionalTimeout || 60000);
5832
- return PSD.trans ?
5833
- PSD.trans.waitFor(promise) :
5834
- promise;
6217
+ const promise = DexiePromise.resolve(typeof promiseOrFunction === 'function'
6218
+ ? Dexie.ignoreTransaction(promiseOrFunction)
6219
+ : promiseOrFunction).timeout(optionalTimeout || 60000);
6220
+ return PSD.trans ? PSD.trans.waitFor(promise) : promise;
5835
6221
  },
5836
6222
  Promise: DexiePromise,
5837
6223
  debug: {
5838
6224
  get: () => debug,
5839
- set: value => {
6225
+ set: (value) => {
5840
6226
  setDebug(value);
5841
- }
6227
+ },
5842
6228
  },
5843
6229
  derive: derive,
5844
6230
  extend: extend,
@@ -5859,24 +6245,25 @@ props(Dexie, {
5859
6245
  minKey: minKey,
5860
6246
  addons: [],
5861
6247
  connections: {
5862
- get: connections.toArray
6248
+ get: connections.toArray,
5863
6249
  },
5864
6250
  errnames: errnames,
5865
6251
  dependencies: domDeps,
5866
6252
  cache,
5867
6253
  semVer: DEXIE_VERSION,
5868
6254
  version: DEXIE_VERSION.split('.')
5869
- .map(n => parseInt(n))
5870
- .reduce((p, c, i) => p + (c / Math.pow(10, i * 2))),
6255
+ .map((n) => parseInt(n))
6256
+ .reduce((p, c, i) => p + c / Math.pow(10, i * 2)),
5871
6257
  });
5872
6258
  Dexie.maxKey = getMaxKey(Dexie.dependencies.IDBKeyRange);
5873
6259
 
5874
- if (typeof dispatchEvent !== 'undefined' && typeof addEventListener !== 'undefined') {
5875
- globalEvents(DEXIE_STORAGE_MUTATED_EVENT_NAME, updatedParts => {
6260
+ if (typeof dispatchEvent !== 'undefined' &&
6261
+ typeof addEventListener !== 'undefined') {
6262
+ globalEvents(DEXIE_STORAGE_MUTATED_EVENT_NAME, (updatedParts) => {
5876
6263
  if (!propagatingLocally) {
5877
6264
  let event;
5878
6265
  event = new CustomEvent(STORAGE_MUTATED_DOM_EVENT_NAME, {
5879
- detail: updatedParts
6266
+ detail: updatedParts,
5880
6267
  });
5881
6268
  propagatingLocally = true;
5882
6269
  dispatchEvent(event);
@@ -5907,7 +6294,7 @@ let createBC = () => { };
5907
6294
  if (typeof BroadcastChannel !== 'undefined') {
5908
6295
  createBC = () => {
5909
6296
  bc = new BroadcastChannel(STORAGE_MUTATED_DOM_EVENT_NAME);
5910
- bc.onmessage = ev => ev.data && propagateLocally(ev.data);
6297
+ bc.onmessage = (ev) => ev.data && propagateLocally(ev.data);
5911
6298
  };
5912
6299
  createBC();
5913
6300
  if (typeof bc.unref === 'function') {