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