indexeddbshim 18.0.0 → 19.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/dist/DOMException.d.ts +3 -7
  2. package/dist/DOMException.d.ts.map +1 -1
  3. package/dist/DOMStringList.d.ts +1 -2
  4. package/dist/DOMStringList.d.ts.map +1 -1
  5. package/dist/IDBCursor.d.ts +100 -52
  6. package/dist/IDBCursor.d.ts.map +1 -1
  7. package/dist/IDBFactory.d.ts.map +1 -1
  8. package/dist/IDBIndex.d.ts +8 -7
  9. package/dist/IDBIndex.d.ts.map +1 -1
  10. package/dist/IDBKeyRange.d.ts +3 -3
  11. package/dist/IDBKeyRange.d.ts.map +1 -1
  12. package/dist/IDBObjectStore.d.ts +12 -12
  13. package/dist/IDBObjectStore.d.ts.map +1 -1
  14. package/dist/IDBRequest.d.ts +2 -2
  15. package/dist/IDBRequest.d.ts.map +1 -1
  16. package/dist/IDBTransaction.d.ts +13 -13
  17. package/dist/IDBTransaction.d.ts.map +1 -1
  18. package/dist/Key.d.ts +14 -15
  19. package/dist/Key.d.ts.map +1 -1
  20. package/dist/Sca.d.ts +2 -2
  21. package/dist/Sca.d.ts.map +1 -1
  22. package/dist/cmp.d.ts +3 -3
  23. package/dist/cmp.d.ts.map +1 -1
  24. package/dist/indexeddbshim-Key.js +36 -45
  25. package/dist/indexeddbshim-Key.js.map +1 -1
  26. package/dist/indexeddbshim-Key.min.js +2 -2
  27. package/dist/indexeddbshim-Key.min.js.map +1 -1
  28. package/dist/indexeddbshim-UnicodeIdentifiers-node.cjs +224 -208
  29. package/dist/indexeddbshim-UnicodeIdentifiers-node.cjs.map +1 -1
  30. package/dist/indexeddbshim-UnicodeIdentifiers.js +221 -235
  31. package/dist/indexeddbshim-UnicodeIdentifiers.js.map +1 -1
  32. package/dist/indexeddbshim-UnicodeIdentifiers.min.js +3 -3
  33. package/dist/indexeddbshim-UnicodeIdentifiers.min.js.map +1 -1
  34. package/dist/indexeddbshim-node.cjs +224 -208
  35. package/dist/indexeddbshim-node.cjs.map +1 -1
  36. package/dist/indexeddbshim-noninvasive.js +221 -235
  37. package/dist/indexeddbshim-noninvasive.js.map +1 -1
  38. package/dist/indexeddbshim-noninvasive.min.js +3 -3
  39. package/dist/indexeddbshim-noninvasive.min.js.map +1 -1
  40. package/dist/indexeddbshim.js +221 -235
  41. package/dist/indexeddbshim.js.map +1 -1
  42. package/dist/indexeddbshim.min.js +3 -3
  43. package/dist/indexeddbshim.min.js.map +1 -1
  44. package/dist/nodeWebSQL.d.ts +2 -2
  45. package/dist/nodeWebSQL.d.ts.map +1 -1
  46. package/dist/setGlobalVars.d.ts +1 -2
  47. package/dist/setGlobalVars.d.ts.map +1 -1
  48. package/dist/util.d.ts +20 -22
  49. package/dist/util.d.ts.map +1 -1
  50. package/package.json +1 -1
  51. package/src/CFG.js +1 -1
  52. package/src/DOMException.js +8 -10
  53. package/src/DOMStringList.js +6 -11
  54. package/src/Event.js +1 -4
  55. package/src/IDBCursor.js +95 -47
  56. package/src/IDBFactory.js +8 -5
  57. package/src/IDBIndex.js +10 -12
  58. package/src/IDBKeyRange.js +6 -5
  59. package/src/IDBObjectStore.js +32 -27
  60. package/src/IDBRequest.js +1 -1
  61. package/src/IDBTransaction.js +11 -11
  62. package/src/IDBVersionChangeEvent.js +1 -4
  63. package/src/Key.js +32 -31
  64. package/src/Sca.js +1 -1
  65. package/src/cmp.js +2 -2
  66. package/src/nodeWebSQL.js +5 -2
  67. package/src/setGlobalVars.js +8 -19
  68. package/src/util.js +19 -16
@@ -15,15 +15,11 @@ import shimIDBDatabase from './IDBDatabase.js';
15
15
  import CFG from './CFG.js';
16
16
  import {isNullish} from './util.js';
17
17
 
18
- /**
19
- * @typedef {any} AnyValue
20
- */
21
-
22
18
  /**
23
19
  * @callback SetConfig
24
20
  * @param {import('./CFG.js').KeyofConfigValues|
25
21
  * Partial<import('./CFG.js').ConfigValues>} prop
26
- * @param {AnyValue} [val]
22
+ * @param {import('./CFG.js').ConfigValue} [val]
27
23
  * @throws {Error}
28
24
  * @returns {void}
29
25
  */
@@ -114,18 +110,9 @@ function setGlobalVars (idb, initialConfig) {
114
110
  const IDB = /** @type {ShimmedObject & {[key: string]: unknown}} */ (
115
111
  /** @type {unknown} */ (idb || globalThis || {})
116
112
  );
117
- /**
118
- * @typedef {any} AnyClass
119
- */
120
- /**
121
- * @typedef {any} AnyValue
122
- */
123
- /**
124
- * @typedef {Function} AnyFunction
125
- */
126
113
  /**
127
114
  * @param {string} name
128
- * @param {AnyClass} value
115
+ * @param {unknown} value
129
116
  * @param {PropertyDescriptor & {
130
117
  * shimNS?: object
131
118
  * }|undefined} [propDesc]
@@ -157,10 +144,10 @@ function setGlobalVars (idb, initialConfig) {
157
144
  } else {
158
145
  const o = {
159
146
  /**
160
- * @returns {AnyValue}
147
+ * @returns {unknown}
161
148
  */
162
149
  get [name] () {
163
- return /** @type {AnyFunction} */ (
150
+ return /** @type {() => unknown} */ (
164
151
  /** @type {PropertyDescriptor} */ (
165
152
  propDesc
166
153
  ).get
@@ -239,7 +226,7 @@ function setGlobalVars (idb, initialConfig) {
239
226
  return shimIndexedDB;
240
227
  }
241
228
  });
242
- /** @type {[string, any][]} */
229
+ /** @type {[string, unknown][]} */
243
230
  ([
244
231
  ['IDBFactory', shimIDBFactory],
245
232
  ['IDBDatabase', shimIDBDatabase],
@@ -339,7 +326,9 @@ function setGlobalVars (idb, initialConfig) {
339
326
  '__useShim', '__debug', '__setConfig',
340
327
  '__getConfig', '__setUnicodeIdentifiers'
341
328
  ]).forEach((prop) => {
342
- /** @type {ShimIndexedDB} */ (IDB.shimIndexedDB)[prop] = /** @type {() => any} */ function () {
329
+ /** @type {{[key: string]: () => void}} */ (
330
+ /** @type {unknown} */ (IDB.shimIndexedDB)
331
+ )[prop] = function () {
343
332
  console.warn('This browser does not have WebSQL to shim.');
344
333
  };
345
334
  });
package/src/util.js CHANGED
@@ -251,9 +251,11 @@ function joinPath (base, name) {
251
251
  return base.replace(/[/\\]+$/u, '') + sep + name;
252
252
  }
253
253
 
254
+ /* eslint-disable jsdoc/valid-types -- Bug */
254
255
  /**
255
- * @typedef {Function} AnyClass
256
+ * @typedef {{[Symbol.hasInstance]: (value: unknown) => boolean}} AnyClass
256
257
  */
258
+ /* eslint-enable jsdoc/valid-types -- Bug */
257
259
 
258
260
  // Babel doesn't seem to provide a means of using the `instanceof` operator with Symbol.hasInstance (yet?)
259
261
  /**
@@ -277,7 +279,7 @@ function isObj (obj) {
277
279
 
278
280
  /**
279
281
  *
280
- * @param {object} obj
282
+ * @param {AnyValue} obj
281
283
  * @returns {boolean}
282
284
  */
283
285
  function isDate (obj) {
@@ -286,7 +288,7 @@ function isDate (obj) {
286
288
 
287
289
  /**
288
290
  *
289
- * @param {object} obj
291
+ * @param {AnyValue} obj
290
292
  * @returns {boolean}
291
293
  */
292
294
  function isBlob (obj) {
@@ -296,7 +298,7 @@ function isBlob (obj) {
296
298
 
297
299
  /**
298
300
  *
299
- * @param {object} obj
301
+ * @param {AnyValue} obj
300
302
  * @returns {boolean}
301
303
  */
302
304
  function isRegExp (obj) {
@@ -306,7 +308,7 @@ function isRegExp (obj) {
306
308
 
307
309
  /**
308
310
  *
309
- * @param {object} obj
311
+ * @param {AnyValue} obj
310
312
  * @returns {boolean}
311
313
  */
312
314
  function isFile (obj) {
@@ -329,7 +331,7 @@ function isBinary (obj) {
329
331
  /**
330
332
  *
331
333
  * @param {AnyValue} obj
332
- * @returns {boolean}
334
+ * @returns {obj is Iterable<unknown>}
333
335
  */
334
336
  function isIterable (obj) {
335
337
  return isObj(obj) &&
@@ -384,9 +386,7 @@ function defineReadonlyOuterInterface (obj, props) {
384
386
 
385
387
  /**
386
388
  *
387
- * @param {object & {
388
- * [key: string]: any
389
- * }} obj
389
+ * @param {object} obj
390
390
  * @param {string[]} listeners
391
391
  * @returns {void}
392
392
  */
@@ -395,13 +395,13 @@ function defineListenerProperties (obj, listeners) {
395
395
  listeners.forEach((listener) => {
396
396
  const o = {
397
397
  get [listener] () {
398
- return obj['__' + listener];
398
+ return Reflect.get(obj, '__' + listener);
399
399
  },
400
400
  /**
401
401
  * @param {AnyValue} val
402
402
  */
403
403
  set [listener] (val) {
404
- obj['__' + listener] = val;
404
+ Reflect.set(obj, '__' + listener, val);
405
405
  }
406
406
  };
407
407
  const desc = /** @type {PropertyDescriptor} */ (
@@ -412,7 +412,7 @@ function defineListenerProperties (obj, listeners) {
412
412
  Object.defineProperty(obj, listener, desc);
413
413
  });
414
414
  listeners.forEach((l) => {
415
- obj[l] = null;
415
+ Reflect.set(obj, l, null);
416
416
  });
417
417
  }
418
418
 
@@ -421,7 +421,7 @@ function defineListenerProperties (obj, listeners) {
421
421
  * @param {object} obj
422
422
  * @param {string|string[]} props
423
423
  * @param {null|{
424
- * [key: string]: any
424
+ * [key: string]: unknown
425
425
  * }} getter
426
426
  * @returns {void}
427
427
  */
@@ -561,7 +561,7 @@ function enforceRange (number, type) {
561
561
  }
562
562
 
563
563
  /**
564
- * @typedef {any} AnyValue
564
+ * @typedef {unknown} AnyValue
565
565
  */
566
566
 
567
567
  /**
@@ -578,8 +578,11 @@ function convertToDOMString (v, treatNullAs) {
578
578
  * @returns {string}
579
579
  */
580
580
  function ToString (o) { // Todo: See `es-abstract/es7`
581
- // `String()` will not throw with Symbols
582
- return '' + o; // eslint-disable-line no-implicit-coercion -- Need to throw with symbols
581
+ // `String()` will not throw with Symbols, but the unchecked `+ ''`
582
+ // coercion deliberately does (Web IDL requires converting a symbol
583
+ // to `DOMString` to throw a `TypeError`); the assertion only tells
584
+ // the compiler to allow the coercion it cannot model.
585
+ return '' + /** @type {string} */ (o); // eslint-disable-line no-implicit-coercion -- Need to throw with symbols
583
586
  }
584
587
 
585
588
  /**