indexeddbshim 11.0.0 → 12.0.0-pre.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 (98) hide show
  1. package/badges/licenses-badge.svg +1 -1
  2. package/dist/CFG.d.ts +80 -0
  3. package/dist/CFG.d.ts.map +1 -0
  4. package/dist/DOMException.d.ts +71 -0
  5. package/dist/DOMException.d.ts.map +1 -0
  6. package/dist/DOMStringList.d.ts +20 -0
  7. package/dist/DOMStringList.d.ts.map +1 -0
  8. package/dist/Event.d.ts +21 -0
  9. package/dist/Event.d.ts.map +1 -0
  10. package/dist/IDBCursor.d.ts +289 -0
  11. package/dist/IDBCursor.d.ts.map +1 -0
  12. package/dist/IDBDatabase.d.ts +144 -0
  13. package/dist/IDBDatabase.d.ts.map +1 -0
  14. package/dist/IDBFactory.d.ts +96 -0
  15. package/dist/IDBFactory.d.ts.map +1 -0
  16. package/dist/IDBIndex.d.ts +243 -0
  17. package/dist/IDBIndex.d.ts.map +1 -0
  18. package/dist/IDBKeyRange.d.ts +79 -0
  19. package/dist/IDBKeyRange.d.ts.map +1 -0
  20. package/dist/IDBObjectStore.d.ts +273 -0
  21. package/dist/IDBObjectStore.d.ts.map +1 -0
  22. package/dist/IDBRequest.d.ts +90 -0
  23. package/dist/IDBRequest.d.ts.map +1 -0
  24. package/dist/IDBTransaction.d.ts +271 -0
  25. package/dist/IDBTransaction.d.ts.map +1 -0
  26. package/dist/IDBVersionChangeEvent.d.ts +23 -0
  27. package/dist/IDBVersionChangeEvent.d.ts.map +1 -0
  28. package/dist/Key.d.ts +214 -0
  29. package/dist/Key.d.ts.map +1 -0
  30. package/dist/Sca.d.ts +31 -0
  31. package/dist/Sca.d.ts.map +1 -0
  32. package/dist/UnicodeIdentifiers.d.ts +3 -0
  33. package/dist/UnicodeIdentifiers.d.ts.map +1 -0
  34. package/dist/browser-UnicodeIdentifiers.d.ts +2 -0
  35. package/dist/browser-UnicodeIdentifiers.d.ts.map +1 -0
  36. package/dist/browser-noninvasive.d.ts +3 -0
  37. package/dist/browser-noninvasive.d.ts.map +1 -0
  38. package/dist/browser.d.ts +2 -0
  39. package/dist/browser.d.ts.map +1 -0
  40. package/dist/cmp.d.ts +9 -0
  41. package/dist/cmp.d.ts.map +1 -0
  42. package/dist/indexeddbshim-Key.js +491 -189
  43. package/dist/indexeddbshim-Key.js.map +1 -1
  44. package/dist/indexeddbshim-Key.min.js +2 -2
  45. package/dist/indexeddbshim-Key.min.js.map +1 -1
  46. package/dist/indexeddbshim-UnicodeIdentifiers-node.cjs +17263 -1396
  47. package/dist/indexeddbshim-UnicodeIdentifiers-node.cjs.map +1 -1
  48. package/dist/indexeddbshim-UnicodeIdentifiers.js +3892 -1271
  49. package/dist/indexeddbshim-UnicodeIdentifiers.js.map +1 -1
  50. package/dist/indexeddbshim-UnicodeIdentifiers.min.js +2 -2
  51. package/dist/indexeddbshim-UnicodeIdentifiers.min.js.map +1 -1
  52. package/dist/indexeddbshim-node.cjs +17259 -1396
  53. package/dist/indexeddbshim-node.cjs.map +1 -1
  54. package/dist/indexeddbshim-noninvasive.js +3887 -1271
  55. package/dist/indexeddbshim-noninvasive.js.map +1 -1
  56. package/dist/indexeddbshim-noninvasive.min.js +2 -2
  57. package/dist/indexeddbshim-noninvasive.min.js.map +1 -1
  58. package/dist/indexeddbshim.js +3887 -1271
  59. package/dist/indexeddbshim.js.map +1 -1
  60. package/dist/indexeddbshim.min.js +2 -2
  61. package/dist/indexeddbshim.min.js.map +1 -1
  62. package/dist/node-UnicodeIdentifiers.d.ts +8 -0
  63. package/dist/node-UnicodeIdentifiers.d.ts.map +1 -0
  64. package/dist/node.d.ts +8 -0
  65. package/dist/node.d.ts.map +1 -0
  66. package/dist/nodeWebSQL.d.ts +3 -0
  67. package/dist/nodeWebSQL.d.ts.map +1 -0
  68. package/dist/setGlobalVars.d.ts +79 -0
  69. package/dist/setGlobalVars.d.ts.map +1 -0
  70. package/dist/unicode-regex.d.ts +3 -0
  71. package/dist/unicode-regex.d.ts.map +1 -0
  72. package/dist/util.d.ts +174 -0
  73. package/dist/util.d.ts.map +1 -0
  74. package/package.json +40 -27
  75. package/src/CFG.js +89 -11
  76. package/src/DOMException.js +116 -29
  77. package/src/DOMStringList.js +92 -2
  78. package/src/Event.js +19 -4
  79. package/src/IDBCursor.js +339 -67
  80. package/src/IDBDatabase.js +87 -10
  81. package/src/IDBFactory.js +319 -56
  82. package/src/IDBIndex.js +385 -96
  83. package/src/IDBKeyRange.js +86 -13
  84. package/src/IDBObjectStore.js +326 -68
  85. package/src/IDBRequest.js +59 -1
  86. package/src/IDBTransaction.js +247 -38
  87. package/src/IDBVersionChangeEvent.js +28 -3
  88. package/src/Key.js +273 -156
  89. package/src/Sca.js +29 -4
  90. package/src/browser-UnicodeIdentifiers.js +5 -1
  91. package/src/cmp.js +5 -5
  92. package/src/node-UnicodeIdentifiers.js +9 -0
  93. package/src/node.js +5 -0
  94. package/src/nodeWebSQL.js +11 -5
  95. package/src/setGlobalVars.js +156 -21
  96. package/src/unicode-regex.js +9 -1
  97. package/src/util.js +228 -40
  98. package/typings/shimIndexedDB.d.ts +9 -0
package/src/util.js CHANGED
@@ -1,9 +1,17 @@
1
1
  import CFG from './CFG.js';
2
2
  import expandsOnNFD from './unicode-regex.js';
3
3
 
4
+ /**
5
+ * @typedef {number} Integer
6
+ */
7
+
8
+ /**
9
+ * @param {string} arg
10
+ * @returns {string}
11
+ */
4
12
  function escapeUnmatchedSurrogates (arg) {
5
13
  // http://stackoverflow.com/a/6701665/271577
6
- return arg.replace(
14
+ return arg.replaceAll(
7
15
  /([\uD800-\uDBFF])(?![\uDC00-\uDFFF])|(^|[^\uD800-\uDBFF])([\uDC00-\uDFFF])/gu,
8
16
  function (_, unmatchedHighSurrogate, precedingLow, unmatchedLowSurrogate) {
9
17
  // Could add a corresponding surrogate for compatibility with `node-sqlite3`: http://bugs.python.org/issue12569 and http://stackoverflow.com/a/6701665/271577
@@ -18,47 +26,73 @@ function escapeUnmatchedSurrogates (arg) {
18
26
  );
19
27
  }
20
28
 
29
+ /**
30
+ * @param {string} arg
31
+ * @returns {string}
32
+ */
21
33
  function escapeNameForSQLiteIdentifier (arg) {
22
34
  // http://stackoverflow.com/a/6701665/271577
23
35
  return '_' + // Prevent empty string
24
36
  escapeUnmatchedSurrogates(
25
- arg.replace(/\^/gu, '^^') // Escape our escape
37
+ arg.replaceAll('^', '^^') // Escape our escape
26
38
  // http://www.sqlite.org/src/tktview?name=57c971fc74
27
- .replace(/\0/gu, '^0')
39
+ .replaceAll('\0', '^0')
28
40
  // We need to avoid identifiers being treated as duplicates based on SQLite's ASCII-only case-insensitive table and column names
29
41
  // (For SQL in general, however, see http://stackoverflow.com/a/17215009/271577
30
42
  // See also https://www.sqlite.org/faq.html#q18 re: Unicode (non-ASCII) case-insensitive not working
31
- .replace(/([A-Z])/gu, '^$1')
43
+ .replaceAll(/([A-Z])/gu, '^$1')
32
44
  );
33
45
  }
34
46
 
35
- // The escaping of unmatched surrogates was needed by Chrome but not Node
47
+ /**
48
+ * The escaping of unmatched surrogates was needed by Chrome but not Node.
49
+ * @param {string} arg
50
+ * @returns {string}
51
+ */
36
52
  function escapeSQLiteStatement (arg) {
37
- return escapeUnmatchedSurrogates(arg.replace(/\^/gu, '^^').replace(/\0/gu, '^0'));
53
+ return escapeUnmatchedSurrogates(arg.replaceAll('^', '^^').replaceAll('\0', '^0'));
38
54
  }
55
+
56
+ /**
57
+ * @param {string} arg
58
+ * @returns {string}
59
+ */
39
60
  function unescapeSQLiteResponse (arg) {
40
61
  return unescapeUnmatchedSurrogates(arg)
41
- .replace(/(\^+)0/gu, (_, esc) => {
62
+ .replaceAll(/(\^+)0/gu, (_, esc) => {
42
63
  return esc.length % 2
43
64
  ? esc.slice(1) + '\0'
44
65
  : _;
45
66
  })
46
- .replace(/\^\^/gu, '^');
67
+ .replaceAll('^^', '^');
47
68
  }
48
69
 
70
+ /**
71
+ * @param {string} arg
72
+ * @returns {string}
73
+ */
49
74
  function sqlEscape (arg) {
50
75
  // https://www.sqlite.org/lang_keywords.html
51
76
  // http://stackoverflow.com/a/6701665/271577
52
77
  // There is no need to escape ', `, or [], as
53
78
  // we should always be within double quotes
54
79
  // NUL should have already been stripped
55
- return arg.replace(/"/gu, '""');
80
+ return arg.replaceAll('"', '""');
56
81
  }
57
82
 
83
+ /**
84
+ * @param {string} arg
85
+ * @returns {string}
86
+ */
58
87
  function sqlQuote (arg) {
59
88
  return '"' + sqlEscape(arg) + '"';
60
89
  }
61
90
 
91
+ /**
92
+ * @param {string} db
93
+ * @throws {Error}
94
+ * @returns {string}
95
+ */
62
96
  function escapeDatabaseNameForSQLAndFiles (db) {
63
97
  if (CFG.escapeDatabaseName) {
64
98
  // We at least ensure NUL is escaped by default, but we need to still
@@ -70,8 +104,8 @@ function escapeDatabaseNameForSQLAndFiles (db) {
70
104
  db = 'D' + escapeNameForSQLiteIdentifier(db);
71
105
  if (CFG.escapeNFDForDatabaseNames !== false) {
72
106
  // ES6 copying of regex with different flags
73
- db = db.replace(new RegExp(expandsOnNFD, 'gu'), function (expandable) {
74
- return '^4' + expandable.codePointAt().toString(16).padStart(6, '0');
107
+ db = db.replaceAll(new RegExp(expandsOnNFD, 'gu'), function (expandable) {
108
+ return '^4' + /** @type {Integer} */ (expandable.codePointAt(0)).toString(16).padStart(6, '0');
75
109
  });
76
110
  }
77
111
  if (CFG.databaseCharacterEscapeList !== false) {
@@ -81,7 +115,7 @@ function escapeDatabaseNameForSQLAndFiles (db) {
81
115
  : /[\u0000-\u001F\u007F"*/:<>?\\|]/gu), // eslint-disable-line no-control-regex
82
116
  function (n0) {
83
117
  // eslint-disable-next-line unicorn/prefer-code-point -- Switch to `codePointAt`?
84
- return '^1' + n0.charCodeAt().toString(16).padStart(2, '0');
118
+ return '^1' + n0.charCodeAt(0).toString(16).padStart(2, '0');
85
119
  }
86
120
  );
87
121
  }
@@ -95,20 +129,28 @@ function escapeDatabaseNameForSQLAndFiles (db) {
95
129
  return db + (CFG.addSQLiteExtension !== false ? '.sqlite' : ''); // Shouldn't have quoting (do we even need NUL/case escaping here?)
96
130
  }
97
131
 
132
+ /**
133
+ * @param {string} arg
134
+ * @returns {string}
135
+ */
98
136
  function unescapeUnmatchedSurrogates (arg) {
99
137
  return arg
100
- .replace(/(\^+)3(d[0-9a-f]{3})/gu, (_, esc, lowSurr) => {
138
+ .replaceAll(/(\^+)3(d[0-9a-f]{3})/gu, (_, esc, lowSurr) => {
101
139
  return esc.length % 2
102
140
  ? esc.slice(1) + String.fromCodePoint(Number.parseInt(lowSurr, 16))
103
141
  : _;
104
- }).replace(/(\^+)2(d[0-9a-f]{3})/gu, (_, esc, highSurr) => {
142
+ }).replaceAll(/(\^+)2(d[0-9a-f]{3})/gu, (_, esc, highSurr) => {
105
143
  return esc.length % 2
106
144
  ? esc.slice(1) + String.fromCodePoint(Number.parseInt(highSurr, 16))
107
145
  : _;
108
146
  });
109
147
  }
110
148
 
111
- // Not in use internally but supplied for convenience
149
+ /**
150
+ * Not in use internally but supplied for convenience.
151
+ * @param {string} db
152
+ * @returns {string}
153
+ */
112
154
  function unescapeDatabaseNameForSQLAndFiles (db) {
113
155
  if (CFG.unescapeDatabaseName) {
114
156
  // We at least ensure NUL is unescaped by default, but we need to still
@@ -121,96 +163,176 @@ function unescapeDatabaseNameForSQLAndFiles (db) {
121
163
  return unescapeUnmatchedSurrogates(
122
164
  db.slice(2) // D_
123
165
  // CFG.databaseCharacterEscapeList
124
- .replace(/(\^+)1([0-9a-f]{2})/gu, (_, esc, hex) => {
166
+ .replaceAll(/(\^+)1([0-9a-f]{2})/gu, (_, esc, hex) => {
125
167
  return esc.length % 2
126
168
  ? esc.slice(1) + String.fromCodePoint(Number.parseInt(hex, 16))
127
169
  : _;
128
170
  // CFG.escapeNFDForDatabaseNames
129
- }).replace(/(\^+)4([0-9a-f]{6})/gu, (_, esc, hex) => {
171
+ }).replaceAll(/(\^+)4([0-9a-f]{6})/gu, (_, esc, hex) => {
130
172
  return esc.length % 2
131
173
  ? esc.slice(1) + String.fromCodePoint(Number.parseInt(hex, 16))
132
174
  : _;
133
175
  })
134
176
  // escapeNameForSQLiteIdentifier (including unescapeUnmatchedSurrogates() above)
135
- ).replace(/(\^+)([A-Z])/gu, (_, esc, upperCase) => {
177
+ ).replaceAll(/(\^+)([A-Z])/gu, (_, esc, upperCase) => {
136
178
  return esc.length % 2
137
179
  ? esc.slice(1) + upperCase
138
180
  : _;
139
- }).replace(/(\^+)0/gu, (_, esc) => {
181
+ }).replaceAll(/(\^+)0/gu, (_, esc) => {
140
182
  return esc.length % 2
141
183
  ? esc.slice(1) + '\0'
142
184
  : _;
143
- }).replace(/\^\^/gu, '^');
185
+ }).replaceAll('^^', '^');
144
186
  }
145
187
 
188
+ /**
189
+ * @param {string} store
190
+ * @returns {string}
191
+ */
146
192
  function escapeStoreNameForSQL (store) {
147
193
  return sqlQuote('S' + escapeNameForSQLiteIdentifier(store));
148
194
  }
149
195
 
196
+ /**
197
+ * @param {string} index
198
+ * @returns {string}
199
+ */
150
200
  function escapeIndexNameForSQL (index) {
151
201
  return sqlQuote('I' + escapeNameForSQLiteIdentifier(index));
152
202
  }
153
203
 
204
+ /**
205
+ * @param {string} index
206
+ * @returns {string}
207
+ */
154
208
  function escapeIndexNameForSQLKeyColumn (index) {
155
209
  return 'I' + escapeNameForSQLiteIdentifier(index);
156
210
  }
157
211
 
212
+ /**
213
+ * @param {string} str
214
+ * @returns {string}
215
+ */
158
216
  function sqlLIKEEscape (str) {
159
217
  // https://www.sqlite.org/lang_expr.html#like
160
- return sqlEscape(str).replace(/\^/gu, '^^');
218
+ return sqlEscape(str).replaceAll('^', '^^');
161
219
  }
162
220
 
221
+ /**
222
+ * @typedef {Function} AnyClass
223
+ */
224
+
163
225
  // Babel doesn't seem to provide a means of using the `instanceof` operator with Symbol.hasInstance (yet?)
226
+ /**
227
+ *
228
+ * @param {AnyValue} obj
229
+ * @param {AnyClass} Clss
230
+ * @returns {boolean}
231
+ */
164
232
  function instanceOf (obj, Clss) {
165
233
  return Clss[Symbol.hasInstance](obj);
166
234
  }
167
235
 
236
+ /**
237
+ *
238
+ * @param {AnyValue} obj
239
+ * @returns {obj is object}
240
+ */
168
241
  function isObj (obj) {
169
- return obj && typeof obj === 'object';
242
+ return obj !== null && typeof obj === 'object';
170
243
  }
171
244
 
245
+ /**
246
+ *
247
+ * @param {object} obj
248
+ * @returns {boolean}
249
+ */
172
250
  function isDate (obj) {
173
- return isObj(obj) && typeof obj.getDate === 'function';
251
+ return isObj(obj) && 'getDate' in obj && typeof obj.getDate === 'function';
174
252
  }
175
253
 
254
+ /**
255
+ *
256
+ * @param {object} obj
257
+ * @returns {boolean}
258
+ */
176
259
  function isBlob (obj) {
177
- return isObj(obj) && typeof obj.size === 'number' && typeof obj.slice === 'function' && !('lastModified' in obj);
260
+ return isObj(obj) && 'size' in obj && typeof obj.size === 'number' &&
261
+ 'slice' in obj && typeof obj.slice === 'function' && !('lastModified' in obj);
178
262
  }
179
263
 
264
+ /**
265
+ *
266
+ * @param {object} obj
267
+ * @returns {boolean}
268
+ */
180
269
  function isRegExp (obj) {
181
- return isObj(obj) && typeof obj.flags === 'string' && typeof obj.exec === 'function';
270
+ return isObj(obj) && 'flags' in obj && typeof obj.flags === 'string' &&
271
+ 'exec' in obj && typeof obj.exec === 'function';
182
272
  }
183
273
 
274
+ /**
275
+ *
276
+ * @param {object} obj
277
+ * @returns {boolean}
278
+ */
184
279
  function isFile (obj) {
185
- return isObj(obj) && typeof obj.name === 'string' && typeof obj.slice === 'function' && 'lastModified' in obj;
280
+ return isObj(obj) && 'name' in obj && typeof obj.name === 'string' &&
281
+ 'slice' in obj && typeof obj.slice === 'function' && 'lastModified' in obj;
186
282
  }
187
283
 
284
+ /**
285
+ *
286
+ * @param {AnyValue} obj
287
+ * @returns {boolean}
288
+ */
188
289
  function isBinary (obj) {
189
- return isObj(obj) && typeof obj.byteLength === 'number' && (
190
- typeof obj.slice === 'function' || // `TypedArray` (view on buffer) or `ArrayBuffer`
191
- typeof obj.getFloat64 === 'function' // `DataView` (view on buffer)
290
+ return isObj(obj) && 'byteLength' in obj && typeof obj.byteLength === 'number' && (
291
+ ('slice' in obj && typeof obj.slice === 'function') || // `TypedArray` (view on buffer) or `ArrayBuffer`
292
+ ('getFloat64' in obj && typeof obj.getFloat64 === 'function') // `DataView` (view on buffer)
192
293
  );
193
294
  }
194
295
 
296
+ /**
297
+ *
298
+ * @param {AnyValue} obj
299
+ * @returns {boolean}
300
+ */
195
301
  function isIterable (obj) {
196
- return isObj(obj) && typeof obj[Symbol.iterator] === 'function';
302
+ return isObj(obj) && Symbol.iterator in obj &&
303
+ typeof obj[Symbol.iterator] === 'function';
197
304
  }
198
305
 
306
+ /**
307
+ *
308
+ * @param {object} obj
309
+ * @param {string[]} props
310
+ * @returns {void}
311
+ */
199
312
  function defineOuterInterface (obj, props) {
200
313
  props.forEach((prop) => {
201
314
  const o = {
202
315
  get [prop] () {
203
316
  throw new TypeError('Illegal invocation');
204
317
  },
318
+ // @ts-expect-error Deliberately errs
205
319
  set [prop] (val) {
206
320
  throw new TypeError('Illegal invocation');
207
321
  }
208
322
  };
209
- const desc = Object.getOwnPropertyDescriptor(o, prop);
323
+ const desc = /** @type {PropertyDescriptor} */ (
324
+ Object.getOwnPropertyDescriptor(o, prop)
325
+ );
210
326
  Object.defineProperty(obj, prop, desc);
211
327
  });
212
328
  }
213
329
 
330
+ /**
331
+ *
332
+ * @param {object} obj
333
+ * @param {string[]} props
334
+ * @returns {void}
335
+ */
214
336
  function defineReadonlyOuterInterface (obj, props) {
215
337
  props.forEach((prop) => {
216
338
  const o = {
@@ -218,11 +340,21 @@ function defineReadonlyOuterInterface (obj, props) {
218
340
  throw new TypeError('Illegal invocation');
219
341
  }
220
342
  };
221
- const desc = Object.getOwnPropertyDescriptor(o, prop);
343
+ const desc = /** @type {PropertyDescriptor} */ (
344
+ Object.getOwnPropertyDescriptor(o, prop)
345
+ );
222
346
  Object.defineProperty(obj, prop, desc);
223
347
  });
224
348
  }
225
349
 
350
+ /**
351
+ *
352
+ * @param {object & {
353
+ * [key: string]: any
354
+ * }} obj
355
+ * @param {string[]} listeners
356
+ * @returns {void}
357
+ */
226
358
  function defineListenerProperties (obj, listeners) {
227
359
  listeners = typeof listeners === 'string' ? [listeners] : listeners;
228
360
  listeners.forEach((listener) => {
@@ -230,11 +362,17 @@ function defineListenerProperties (obj, listeners) {
230
362
  get [listener] () {
231
363
  return obj['__' + listener];
232
364
  },
365
+ /**
366
+ * @param {AnyValue} val
367
+ * @returns {void}
368
+ */
233
369
  set [listener] (val) {
234
370
  obj['__' + listener] = val;
235
371
  }
236
372
  };
237
- const desc = Object.getOwnPropertyDescriptor(o, listener);
373
+ const desc = /** @type {PropertyDescriptor} */ (
374
+ Object.getOwnPropertyDescriptor(o, listener)
375
+ );
238
376
  // desc.enumerable = true; // Default
239
377
  // desc.configurable = true; // Default // Needed by support.js in W3C IndexedDB tests (for openListeners)
240
378
  Object.defineProperty(obj, listener, desc);
@@ -244,6 +382,15 @@ function defineListenerProperties (obj, listeners) {
244
382
  });
245
383
  }
246
384
 
385
+ /**
386
+ *
387
+ * @param {object} obj
388
+ * @param {string|string[]} props
389
+ * @param {null|{
390
+ * [key: string]: any
391
+ * }} getter
392
+ * @returns {void}
393
+ */
247
394
  function defineReadonlyProperties (obj, props, getter = null) {
248
395
  props = typeof props === 'string' ? [props] : props;
249
396
  props.forEach(function (prop) {
@@ -265,13 +412,20 @@ function defineReadonlyProperties (obj, props, getter = null) {
265
412
  };
266
413
  }
267
414
 
268
- const desc = Object.getOwnPropertyDescriptor(o, prop);
415
+ const desc = /** @type {PropertyDescriptor} */ (
416
+ Object.getOwnPropertyDescriptor(o, prop)
417
+ );
269
418
  // desc.enumerable = true; // Default
270
419
  // desc.configurable = true; // Default
271
420
  Object.defineProperty(obj, prop, desc);
272
421
  });
273
422
  }
274
423
 
424
+ /**
425
+ *
426
+ * @param {string} item
427
+ * @returns {boolean}
428
+ */
275
429
  function isIdentifier (item) {
276
430
  // For load-time and run-time performance, we don't provide the complete regular
277
431
  // expression for identifiers, but these can be passed in, using the expressions
@@ -285,6 +439,11 @@ function isIdentifier (item) {
285
439
  return (new RegExp('^' + IdentifierStart + IdentifierPart + '*$', 'u')).test(item);
286
440
  }
287
441
 
442
+ /**
443
+ *
444
+ * @param {string|string[]} keyPathString
445
+ * @returns {boolean}
446
+ */
288
447
  function isValidKeyPathString (keyPathString) {
289
448
  return typeof keyPathString === 'string' &&
290
449
  (keyPathString === '' || isIdentifier(keyPathString) || keyPathString.split('.').every((pathComponent) => {
@@ -292,9 +451,14 @@ function isValidKeyPathString (keyPathString) {
292
451
  }));
293
452
  }
294
453
 
454
+ /**
455
+ *
456
+ * @param {string|string[]} keyPath
457
+ * @returns {boolean}
458
+ */
295
459
  function isValidKeyPath (keyPath) {
296
460
  return isValidKeyPathString(keyPath) || (
297
- Array.isArray(keyPath) && keyPath.length &&
461
+ Array.isArray(keyPath) && Boolean(keyPath.length) &&
298
462
  // Convert array from sparse to dense http://www.2ality.com/2012/06/dense-arrays.html
299
463
  // See also https://heycam.github.io/webidl/#idl-DOMString
300
464
  [...keyPath].every((pathComponent) => {
@@ -303,6 +467,12 @@ function isValidKeyPath (keyPath) {
303
467
  );
304
468
  }
305
469
 
470
+ /**
471
+ * @param {number} number
472
+ * @param {"unsigned long long"|"unsigned long"} type
473
+ * @throws {Error|TypeError}
474
+ * @returns {number}
475
+ */
306
476
  function enforceRange (number, type) {
307
477
  number = Math.floor(Number(number));
308
478
  let max, min;
@@ -328,15 +498,33 @@ function enforceRange (number, type) {
328
498
  return number;
329
499
  }
330
500
 
501
+ /**
502
+ * @typedef {any} AnyValue
503
+ */
504
+
505
+ /**
506
+ * @param {AnyValue} v
507
+ * @param {boolean} [treatNullAs]
508
+ * @returns {string}
509
+ */
331
510
  function convertToDOMString (v, treatNullAs) {
332
511
  return v === null && treatNullAs ? '' : ToString(v);
333
512
  }
334
513
 
514
+ /**
515
+ * @param {AnyValue} o
516
+ * @returns {string}
517
+ */
335
518
  function ToString (o) { // Todo: See `es-abstract/es7`
336
519
  // `String()` will not throw with Symbols
337
520
  return '' + o; // eslint-disable-line no-implicit-coercion
338
521
  }
339
522
 
523
+ /**
524
+ *
525
+ * @param {AnyValue} val
526
+ * @returns {string|string[]}
527
+ */
340
528
  function convertToSequenceDOMString (val) {
341
529
  // Per <https://heycam.github.io/webidl/#idl-sequence>, converting to a sequence works with iterables
342
530
  if (isIterable(val)) { // We don't want conversion to array to convert primitives
@@ -348,14 +536,14 @@ function convertToSequenceDOMString (val) {
348
536
  return ToString(val);
349
537
  }
350
538
 
539
+ /**
540
+ * @param {AnyValue} v
541
+ * @returns {v is null|undefined}
542
+ */
351
543
  function isNullish (v) {
352
544
  return v === null || v === undefined;
353
545
  }
354
546
 
355
- function hasOwn (obj, prop) {
356
- return Object.prototype.hasOwnProperty.call(obj, prop);
357
- }
358
-
359
547
  export {escapeSQLiteStatement, unescapeSQLiteResponse,
360
548
  escapeDatabaseNameForSQLAndFiles, unescapeDatabaseNameForSQLAndFiles,
361
549
  escapeStoreNameForSQL, escapeIndexNameForSQL, escapeIndexNameForSQLKeyColumn,
@@ -366,4 +554,4 @@ export {escapeSQLiteStatement, unescapeSQLiteResponse,
366
554
  defineListenerProperties, defineReadonlyProperties,
367
555
  isValidKeyPath, enforceRange,
368
556
  convertToDOMString, convertToSequenceDOMString,
369
- isNullish, hasOwn};
557
+ isNullish};
@@ -0,0 +1,9 @@
1
+ declare var shimIndexedDB: import('../src/IDBFactory.js').IDBFactory & WindowDatabase & {
2
+ __useShim: () => void
3
+ __debug: (val: boolean) => void
4
+ __setConfig: (prop: string, val: import('../src/CFG.js').ConfigValue) => void
5
+ __getConfig: (prop: string) => import('../src/CFG.js').ConfigValue
6
+ __setUnicodeIdentifiers: (cfg?: {
7
+ UnicodeIDStart: string, UnicodeIDContinue: string
8
+ }) => void
9
+ };