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.
- package/README.md +1 -1
- package/badges/licenses-badge-dev.svg +1 -1
- package/dist/CFG.d.ts +80 -0
- package/dist/CFG.d.ts.map +1 -0
- package/dist/DOMException.d.ts +71 -0
- package/dist/DOMException.d.ts.map +1 -0
- package/dist/DOMStringList.d.ts +20 -0
- package/dist/DOMStringList.d.ts.map +1 -0
- package/dist/Event.d.ts +21 -0
- package/dist/Event.d.ts.map +1 -0
- package/dist/IDBCursor.d.ts +288 -0
- package/dist/IDBCursor.d.ts.map +1 -0
- package/dist/IDBDatabase.d.ts +143 -0
- package/dist/IDBDatabase.d.ts.map +1 -0
- package/dist/IDBFactory.d.ts +96 -0
- package/dist/IDBFactory.d.ts.map +1 -0
- package/dist/IDBIndex.d.ts +243 -0
- package/dist/IDBIndex.d.ts.map +1 -0
- package/dist/IDBKeyRange.d.ts +79 -0
- package/dist/IDBKeyRange.d.ts.map +1 -0
- package/dist/IDBObjectStore.d.ts +273 -0
- package/dist/IDBObjectStore.d.ts.map +1 -0
- package/dist/IDBRequest.d.ts +88 -0
- package/dist/IDBRequest.d.ts.map +1 -0
- package/dist/IDBTransaction.d.ts +270 -0
- package/dist/IDBTransaction.d.ts.map +1 -0
- package/dist/IDBVersionChangeEvent.d.ts +22 -0
- package/dist/IDBVersionChangeEvent.d.ts.map +1 -0
- package/dist/Key.d.ts +214 -0
- package/dist/Key.d.ts.map +1 -0
- package/dist/Sca.d.ts +31 -0
- package/dist/Sca.d.ts.map +1 -0
- package/dist/UnicodeIdentifiers.d.ts +3 -0
- package/dist/UnicodeIdentifiers.d.ts.map +1 -0
- package/dist/browser-UnicodeIdentifiers.d.ts +2 -0
- package/dist/browser-UnicodeIdentifiers.d.ts.map +1 -0
- package/dist/browser-noninvasive.d.ts +3 -0
- package/dist/browser-noninvasive.d.ts.map +1 -0
- package/dist/browser.d.ts +2 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/cmp.d.ts +9 -0
- package/dist/cmp.d.ts.map +1 -0
- package/dist/indexeddbshim-Key.js +553 -252
- package/dist/indexeddbshim-Key.js.map +1 -1
- package/dist/indexeddbshim-Key.min.js +2 -2
- package/dist/indexeddbshim-Key.min.js.map +1 -1
- package/dist/indexeddbshim-UnicodeIdentifiers-node.cjs +17560 -1302
- package/dist/indexeddbshim-UnicodeIdentifiers-node.cjs.map +1 -1
- package/dist/indexeddbshim-UnicodeIdentifiers.js +4367 -1604
- package/dist/indexeddbshim-UnicodeIdentifiers.js.map +1 -1
- package/dist/indexeddbshim-UnicodeIdentifiers.min.js +2 -2
- package/dist/indexeddbshim-UnicodeIdentifiers.min.js.map +1 -1
- package/dist/indexeddbshim-node.cjs +17556 -1302
- package/dist/indexeddbshim-node.cjs.map +1 -1
- package/dist/indexeddbshim-noninvasive.js +4362 -1604
- package/dist/indexeddbshim-noninvasive.js.map +1 -1
- package/dist/indexeddbshim-noninvasive.min.js +2 -2
- package/dist/indexeddbshim-noninvasive.min.js.map +1 -1
- package/dist/indexeddbshim.js +4362 -1604
- package/dist/indexeddbshim.js.map +1 -1
- package/dist/indexeddbshim.min.js +2 -2
- package/dist/indexeddbshim.min.js.map +1 -1
- package/dist/node-UnicodeIdentifiers.d.ts +8 -0
- package/dist/node-UnicodeIdentifiers.d.ts.map +1 -0
- package/dist/node.d.ts +8 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/nodeWebSQL.d.ts +3 -0
- package/dist/nodeWebSQL.d.ts.map +1 -0
- package/dist/setGlobalVars.d.ts +79 -0
- package/dist/setGlobalVars.d.ts.map +1 -0
- package/dist/unicode-regex.d.ts +3 -0
- package/dist/unicode-regex.d.ts.map +1 -0
- package/dist/util.d.ts +174 -0
- package/dist/util.d.ts.map +1 -0
- package/index.html +1 -1
- package/package.json +51 -37
- package/src/CFG.js +89 -11
- package/src/DOMException.js +117 -31
- package/src/DOMStringList.js +93 -3
- package/src/Event.js +19 -4
- package/src/IDBCursor.js +350 -76
- package/src/IDBDatabase.js +88 -10
- package/src/IDBFactory.js +331 -61
- package/src/IDBIndex.js +393 -110
- package/src/IDBKeyRange.js +90 -17
- package/src/IDBObjectStore.js +347 -86
- package/src/IDBRequest.js +59 -1
- package/src/IDBTransaction.js +254 -46
- package/src/IDBVersionChangeEvent.js +28 -3
- package/src/Key.d.ts +1 -0
- package/src/Key.js +272 -162
- package/src/Sca.js +29 -4
- package/src/browser-UnicodeIdentifiers.js +5 -1
- package/src/cmp.js +5 -5
- package/src/node-UnicodeIdentifiers.js +9 -0
- package/src/node.js +5 -0
- package/src/nodeWebSQL.js +11 -5
- package/src/setGlobalVars.js +159 -22
- package/src/unicode-regex.js +2 -0
- package/src/util.js +229 -40
- package/typings/shimIndexedDB.d.ts +9 -0
package/src/Key.js
CHANGED
|
@@ -4,12 +4,57 @@ import cmp from './cmp.js';
|
|
|
4
4
|
import CFG from './CFG.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* @
|
|
7
|
+
* @typedef {NodeJS.TypedArray|DataView} ArrayBufferView
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @typedef {ArrayBufferView|ArrayBuffer} BufferSource
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @typedef {"number"|"date"|"string"|"binary"|"array"} KeyType
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @typedef {any} Value
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @typedef {any} Key
|
|
24
|
+
* @todo Specify possible value more precisely
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @typedef {KeyPath[]} KeyPathArray
|
|
29
|
+
*/
|
|
30
|
+
/**
|
|
31
|
+
* @typedef {string|KeyPathArray} KeyPath
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @typedef {object} KeyValueObject
|
|
36
|
+
* @property {KeyType|"NaN"|"null"|"undefined"|"boolean"|"object"|"symbol"|
|
|
37
|
+
* "function"|"bigint"} type If not `KeyType`, indicates invalid value
|
|
38
|
+
* @property {Value} [value]
|
|
39
|
+
* @property {boolean} [invalid]
|
|
40
|
+
* @property {string} [message]
|
|
41
|
+
* @todo Specify acceptable `value` more precisely
|
|
42
|
+
*/
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* @typedef {number|string|Date|ArrayBuffer} ValueTypePrimitive
|
|
46
|
+
*/
|
|
47
|
+
/**
|
|
48
|
+
* @typedef {ValueType[]} ValueTypeArray
|
|
49
|
+
*/
|
|
50
|
+
/**
|
|
51
|
+
* @typedef {ValueTypePrimitive|ValueTypeArray} ValueType
|
|
8
52
|
*/
|
|
9
53
|
|
|
10
54
|
/**
|
|
11
55
|
* Encodes the keys based on their types. This is required to maintain collations
|
|
12
56
|
* We leave space for future keys.
|
|
57
|
+
* @type {{[key: string]: Integer|string}}
|
|
13
58
|
*/
|
|
14
59
|
const keyTypeToEncodedChar = {
|
|
15
60
|
invalid: 100,
|
|
@@ -19,15 +64,17 @@ const keyTypeToEncodedChar = {
|
|
|
19
64
|
binary: 500,
|
|
20
65
|
array: 600
|
|
21
66
|
};
|
|
22
|
-
const keyTypes = Object.keys(keyTypeToEncodedChar);
|
|
67
|
+
const keyTypes = /** @type {(KeyType|"invalid")[]} */ (Object.keys(keyTypeToEncodedChar));
|
|
23
68
|
keyTypes.forEach((k) => {
|
|
24
|
-
keyTypeToEncodedChar[k] = String.fromCodePoint(
|
|
69
|
+
keyTypeToEncodedChar[k] = String.fromCodePoint(
|
|
70
|
+
/** @type {number} */ (keyTypeToEncodedChar[k])
|
|
71
|
+
);
|
|
25
72
|
});
|
|
26
73
|
|
|
27
74
|
const encodedCharToKeyType = keyTypes.reduce((o, k) => {
|
|
28
75
|
o[keyTypeToEncodedChar[k]] = k;
|
|
29
76
|
return o;
|
|
30
|
-
}, {});
|
|
77
|
+
}, /** @type {{[key: string]: KeyType|"invalid"}} */ ({}));
|
|
31
78
|
|
|
32
79
|
/**
|
|
33
80
|
* The sign values for numbers, ordered from least to greatest.
|
|
@@ -40,12 +87,22 @@ const encodedCharToKeyType = keyTypes.reduce((o, k) => {
|
|
|
40
87
|
*/
|
|
41
88
|
const signValues = ['negativeInfinity', 'bigNegative', 'smallNegative', 'smallPositive', 'bigPositive', 'positiveInfinity'];
|
|
42
89
|
|
|
90
|
+
/**
|
|
91
|
+
* @typedef {any} AnyValue
|
|
92
|
+
*/
|
|
93
|
+
|
|
43
94
|
const types = {
|
|
44
95
|
invalid: {
|
|
45
|
-
|
|
96
|
+
/**
|
|
97
|
+
* @returns {string}
|
|
98
|
+
*/
|
|
99
|
+
encode () {
|
|
46
100
|
return keyTypeToEncodedChar.invalid + '-';
|
|
47
101
|
},
|
|
48
|
-
|
|
102
|
+
/**
|
|
103
|
+
* @returns {undefined}
|
|
104
|
+
*/
|
|
105
|
+
decode () {
|
|
49
106
|
return undefined;
|
|
50
107
|
}
|
|
51
108
|
},
|
|
@@ -63,6 +120,10 @@ const types = {
|
|
|
63
120
|
number: {
|
|
64
121
|
// The encode step checks for six numeric cases and generates 14-digit encoded
|
|
65
122
|
// sign-exponent-mantissa strings.
|
|
123
|
+
/**
|
|
124
|
+
* @param {number} key
|
|
125
|
+
* @returns {string}
|
|
126
|
+
*/
|
|
66
127
|
encode (key) {
|
|
67
128
|
let key32 = key === Number.MIN_VALUE
|
|
68
129
|
// Mocha test `IDBFactory/cmp-spec.js` exposed problem for some
|
|
@@ -128,6 +189,10 @@ const types = {
|
|
|
128
189
|
// The decode step must interpret the sign, reflip values encoded as the 32's complements,
|
|
129
190
|
// apply signs to the exponent and mantissa, do the base-32 power operation, and return
|
|
130
191
|
// the original JavaScript number values.
|
|
192
|
+
/**
|
|
193
|
+
* @param {string} key
|
|
194
|
+
* @returns {number}
|
|
195
|
+
*/
|
|
131
196
|
decode (key) {
|
|
132
197
|
const sign = Number(key.slice(2, 3));
|
|
133
198
|
let exponent = key.slice(3, 5);
|
|
@@ -166,18 +231,28 @@ const types = {
|
|
|
166
231
|
// This effectively doubles the size of every string, but it ensures that when two arrays of strings are compared,
|
|
167
232
|
// the indexes of each string's characters line up with each other.
|
|
168
233
|
string: {
|
|
234
|
+
/**
|
|
235
|
+
* @param {string} key
|
|
236
|
+
* @param {boolean} [inArray]
|
|
237
|
+
* @returns {string}
|
|
238
|
+
*/
|
|
169
239
|
encode (key, inArray) {
|
|
170
240
|
if (inArray) {
|
|
171
241
|
// prepend each character with a dash, and append a space to the end
|
|
172
|
-
key = key.
|
|
242
|
+
key = key.replaceAll(/(.)/gu, '-$1') + ' ';
|
|
173
243
|
}
|
|
174
244
|
return keyTypeToEncodedChar.string + '-' + key;
|
|
175
245
|
},
|
|
246
|
+
/**
|
|
247
|
+
* @param {string} key
|
|
248
|
+
* @param {boolean} [inArray]
|
|
249
|
+
* @returns {string}
|
|
250
|
+
*/
|
|
176
251
|
decode (key, inArray) {
|
|
177
252
|
key = key.slice(2);
|
|
178
253
|
if (inArray) {
|
|
179
254
|
// remove the space at the end, and the dash before each character
|
|
180
|
-
key = key.slice(0, -1).
|
|
255
|
+
key = key.slice(0, -1).replaceAll(/-(.)/gu, '$1');
|
|
181
256
|
}
|
|
182
257
|
return key;
|
|
183
258
|
}
|
|
@@ -187,6 +262,10 @@ const types = {
|
|
|
187
262
|
// An extra, value is added to each array during encoding to make
|
|
188
263
|
// empty arrays sort correctly.
|
|
189
264
|
array: {
|
|
265
|
+
/**
|
|
266
|
+
* @param {ValueTypeArray} key
|
|
267
|
+
* @returns {string}
|
|
268
|
+
*/
|
|
190
269
|
encode (key) {
|
|
191
270
|
const encoded = [];
|
|
192
271
|
for (const [i, item] of key.entries()) {
|
|
@@ -196,6 +275,10 @@ const types = {
|
|
|
196
275
|
encoded.push(keyTypeToEncodedChar.invalid + '-'); // append an extra item, so empty arrays sort correctly
|
|
197
276
|
return keyTypeToEncodedChar.array + '-' + JSON.stringify(encoded);
|
|
198
277
|
},
|
|
278
|
+
/**
|
|
279
|
+
* @param {string} key
|
|
280
|
+
* @returns {ValueTypeArray}
|
|
281
|
+
*/
|
|
199
282
|
decode (key) {
|
|
200
283
|
const decoded = JSON.parse(key.slice(2));
|
|
201
284
|
decoded.pop(); // remove the extra item
|
|
@@ -210,15 +293,27 @@ const types = {
|
|
|
210
293
|
|
|
211
294
|
// Dates are encoded as ISO 8601 strings, in UTC time zone.
|
|
212
295
|
date: {
|
|
296
|
+
/**
|
|
297
|
+
* @param {Date} key
|
|
298
|
+
* @returns {string}
|
|
299
|
+
*/
|
|
213
300
|
encode (key) {
|
|
214
301
|
return keyTypeToEncodedChar.date + '-' + key.toJSON();
|
|
215
302
|
},
|
|
303
|
+
/**
|
|
304
|
+
* @param {string} key
|
|
305
|
+
* @returns {Date}
|
|
306
|
+
*/
|
|
216
307
|
decode (key) {
|
|
217
308
|
return new Date(key.slice(2));
|
|
218
309
|
}
|
|
219
310
|
},
|
|
220
311
|
binary: {
|
|
221
312
|
// `ArrayBuffer`/Views on buffers (`TypedArray` or `DataView`)
|
|
313
|
+
/**
|
|
314
|
+
* @param {BufferSource} key
|
|
315
|
+
* @returns {string}
|
|
316
|
+
*/
|
|
222
317
|
encode (key) {
|
|
223
318
|
return keyTypeToEncodedChar.binary + '-' + (key.byteLength
|
|
224
319
|
? [...getCopyBytesHeldByBufferSource(key)].map(
|
|
@@ -226,6 +321,10 @@ const types = {
|
|
|
226
321
|
) // e.g., '255,005,254,000,001,033'
|
|
227
322
|
: '');
|
|
228
323
|
},
|
|
324
|
+
/**
|
|
325
|
+
* @param {string} key
|
|
326
|
+
* @returns {ArrayBuffer}
|
|
327
|
+
*/
|
|
229
328
|
decode (key) {
|
|
230
329
|
// Set the entries in buffer's [[ArrayBufferData]] to those in `value`
|
|
231
330
|
const k = key.slice(2);
|
|
@@ -244,8 +343,8 @@ const types = {
|
|
|
244
343
|
* @returns {string}
|
|
245
344
|
*/
|
|
246
345
|
function padBase32Exponent (n) {
|
|
247
|
-
|
|
248
|
-
return (
|
|
346
|
+
const exp = n.toString(32);
|
|
347
|
+
return (exp.length === 1) ? '0' + exp : exp;
|
|
249
348
|
}
|
|
250
349
|
|
|
251
350
|
/**
|
|
@@ -283,26 +382,30 @@ function flipBase32 (encoded) {
|
|
|
283
382
|
* @returns {number}
|
|
284
383
|
*/
|
|
285
384
|
function pow32 (mantissa, exponent) {
|
|
286
|
-
|
|
287
|
-
if (
|
|
385
|
+
const exp = Number.parseInt(exponent, 32);
|
|
386
|
+
if (exp < 0) {
|
|
288
387
|
return roundToPrecision(
|
|
289
|
-
Number.parseInt(mantissa, 32) * (32 ** (
|
|
388
|
+
Number.parseInt(mantissa, 32) * (32 ** (exp - 10))
|
|
290
389
|
);
|
|
291
390
|
}
|
|
292
|
-
if (
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
return roundToPrecision(
|
|
391
|
+
if (exp < 11) {
|
|
392
|
+
const whole = mantissa.slice(0, exp);
|
|
393
|
+
const wholeNum = Number.parseInt(whole, 32);
|
|
394
|
+
const fraction = mantissa.slice(exp);
|
|
395
|
+
const fractionNum = Number.parseInt(fraction, 32) * (32 ** (exp - 11));
|
|
396
|
+
return roundToPrecision(wholeNum + fractionNum);
|
|
298
397
|
}
|
|
299
|
-
const expansion = mantissa + zeros(
|
|
398
|
+
const expansion = mantissa + zeros(exp - 11);
|
|
300
399
|
return Number.parseInt(expansion, 32);
|
|
301
400
|
}
|
|
302
401
|
|
|
402
|
+
/**
|
|
403
|
+
* @typedef {number} Float
|
|
404
|
+
*/
|
|
405
|
+
|
|
303
406
|
/**
|
|
304
407
|
* @param {Float} num
|
|
305
|
-
* @param {Float} [precision
|
|
408
|
+
* @param {Float} [precision]
|
|
306
409
|
* @returns {Float}
|
|
307
410
|
*/
|
|
308
411
|
function roundToPrecision (num, precision = 16) {
|
|
@@ -328,27 +431,25 @@ function negate (s) {
|
|
|
328
431
|
}
|
|
329
432
|
|
|
330
433
|
/**
|
|
331
|
-
* @
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
/**
|
|
335
|
-
* @param key
|
|
336
|
-
* @returns {module:Key.KeyType}
|
|
434
|
+
* @param {Key} key
|
|
435
|
+
* @returns {KeyType|"invalid"}
|
|
337
436
|
*/
|
|
338
437
|
function getKeyType (key) {
|
|
339
|
-
if (Array.isArray(key)) return 'array';
|
|
340
|
-
if (util.isDate(key)) return 'date';
|
|
341
|
-
if (util.isBinary(key)) return 'binary';
|
|
438
|
+
if (Array.isArray(key)) { return 'array'; }
|
|
439
|
+
if (util.isDate(key)) { return 'date'; }
|
|
440
|
+
if (util.isBinary(key)) { return 'binary'; }
|
|
342
441
|
const keyType = typeof key;
|
|
343
|
-
return ['string', 'number'].includes(keyType)
|
|
442
|
+
return ['string', 'number'].includes(keyType)
|
|
443
|
+
? /** @type {"string"|"number"} */ (keyType)
|
|
444
|
+
: 'invalid';
|
|
344
445
|
}
|
|
345
446
|
|
|
346
447
|
/**
|
|
347
448
|
* Keys must be strings, numbers (besides `NaN`), Dates (if value is not
|
|
348
449
|
* `NaN`), binary objects or Arrays.
|
|
349
|
-
* @param input The key input
|
|
350
|
-
* @param {
|
|
351
|
-
* @returns {
|
|
450
|
+
* @param {Value} input The key input
|
|
451
|
+
* @param {Value[]|null|undefined} [seen] An array of already seen keys
|
|
452
|
+
* @returns {KeyValueObject}
|
|
352
453
|
*/
|
|
353
454
|
function convertValueToKey (input, seen) {
|
|
354
455
|
return convertValueToKeyValueDecoded(input, seen, false, true);
|
|
@@ -356,8 +457,8 @@ function convertValueToKey (input, seen) {
|
|
|
356
457
|
|
|
357
458
|
/**
|
|
358
459
|
* Currently not in use.
|
|
359
|
-
* @param input
|
|
360
|
-
* @returns {
|
|
460
|
+
* @param {Value} input
|
|
461
|
+
* @returns {KeyValueObject}
|
|
361
462
|
*/
|
|
362
463
|
function convertValueToMultiEntryKey (input) {
|
|
363
464
|
return convertValueToKeyValueDecoded(input, null, true, true);
|
|
@@ -365,7 +466,7 @@ function convertValueToMultiEntryKey (input) {
|
|
|
365
466
|
|
|
366
467
|
/**
|
|
367
468
|
*
|
|
368
|
-
* @param O
|
|
469
|
+
* @param {BufferSource} O
|
|
369
470
|
* @throws {TypeError}
|
|
370
471
|
* @see https://heycam.github.io/webidl/#ref-for-dfn-get-buffer-source-copy-2
|
|
371
472
|
* @returns {Uint8Array}
|
|
@@ -387,29 +488,26 @@ function getCopyBytesHeldByBufferSource (O) {
|
|
|
387
488
|
}
|
|
388
489
|
// const octets = new Uint8Array(input);
|
|
389
490
|
// const octets = types.binary.decode(types.binary.encode(input));
|
|
390
|
-
return new Uint8Array(
|
|
491
|
+
return new Uint8Array(
|
|
492
|
+
// Should allow DataView
|
|
493
|
+
/** @type {ArrayBuffer} */
|
|
494
|
+
(('buffer' in O && O.buffer) || O),
|
|
495
|
+
offset,
|
|
496
|
+
length
|
|
497
|
+
);
|
|
391
498
|
}
|
|
392
499
|
|
|
393
|
-
/**
|
|
394
|
-
* @typedef {PlainObject} module:Key.keyValueObject
|
|
395
|
-
* @property {module:Key.KeyType|"NaN"} type
|
|
396
|
-
* @property {*} [value]
|
|
397
|
-
* @property {boolean} [invalid]
|
|
398
|
-
* @property {string} [message]
|
|
399
|
-
* @todo Specify acceptable `value` more precisely
|
|
400
|
-
*/
|
|
401
|
-
|
|
402
500
|
/**
|
|
403
501
|
* Shortcut utility to avoid returning full keys from `convertValueToKey`
|
|
404
502
|
* and subsequent need to process in calling code unless `fullKeys` is
|
|
405
503
|
* set; may throw.
|
|
406
|
-
* @param {
|
|
407
|
-
* @param {
|
|
504
|
+
* @param {Value} input
|
|
505
|
+
* @param {Value[]|null} [seen]
|
|
408
506
|
* @param {boolean} [multiEntry]
|
|
409
507
|
* @param {boolean} [fullKeys]
|
|
410
508
|
* @throws {TypeError} See `getCopyBytesHeldByBufferSource`
|
|
411
509
|
* @todo Document other allowable `input`
|
|
412
|
-
* @returns {
|
|
510
|
+
* @returns {KeyValueObject}
|
|
413
511
|
*/
|
|
414
512
|
function convertValueToKeyValueDecoded (input, seen, multiEntry, fullKeys) {
|
|
415
513
|
seen = seen || [];
|
|
@@ -434,24 +532,29 @@ function convertValueToKeyValueDecoded (input, seen, multiEntry, fullKeys) {
|
|
|
434
532
|
if (Object.is(input, -0)) {
|
|
435
533
|
return {type, value: 0};
|
|
436
534
|
}
|
|
437
|
-
return ret;
|
|
535
|
+
return /** @type {{type: KeyType; value: Value}} */ (ret);
|
|
438
536
|
} case 'string': {
|
|
439
|
-
return ret;
|
|
537
|
+
return /** @type {{type: KeyType; value: Value}} */ (ret);
|
|
440
538
|
} case 'binary': { // May throw (if detached)
|
|
441
539
|
// Get a copy of the bytes held by the buffer source
|
|
442
540
|
// https://heycam.github.io/webidl/#ref-for-dfn-get-buffer-source-copy-2
|
|
443
|
-
const octets = getCopyBytesHeldByBufferSource(
|
|
541
|
+
const octets = getCopyBytesHeldByBufferSource(
|
|
542
|
+
/** @type {BufferSource} */ (input)
|
|
543
|
+
);
|
|
444
544
|
return {type: 'binary', value: octets};
|
|
445
545
|
} case 'array': { // May throw (from binary)
|
|
446
|
-
const
|
|
546
|
+
const arr = /** @type {Array<any>} */ (input);
|
|
547
|
+
const len = arr.length;
|
|
447
548
|
seen.push(input);
|
|
549
|
+
|
|
550
|
+
/** @type {(KeyValueObject|Value)[]} */
|
|
448
551
|
const keys = [];
|
|
449
552
|
for (let i = 0; i < len; i++) { // We cannot iterate here with array extras as we must ensure sparse arrays are invalidated
|
|
450
|
-
if (!multiEntry && !Object.
|
|
553
|
+
if (!multiEntry && !Object.hasOwn(arr, i)) {
|
|
451
554
|
return {type, invalid: true, message: 'Does not have own index property'};
|
|
452
555
|
}
|
|
453
556
|
try {
|
|
454
|
-
const entry =
|
|
557
|
+
const entry = arr[i];
|
|
455
558
|
const key = convertValueToKeyValueDecoded(entry, seen, false, fullKeys); // Though steps do not list rethrowing, the next is returnifabrupt when not multiEntry
|
|
456
559
|
if (key.invalid) {
|
|
457
560
|
if (multiEntry) {
|
|
@@ -473,32 +576,28 @@ function convertValueToKeyValueDecoded (input, seen, multiEntry, fullKeys) {
|
|
|
473
576
|
}
|
|
474
577
|
return {type, value: keys};
|
|
475
578
|
} case 'date': {
|
|
476
|
-
|
|
579
|
+
const date = /** @type {Date} */ (input);
|
|
580
|
+
if (!Number.isNaN(date.getTime())) {
|
|
477
581
|
return fullKeys
|
|
478
|
-
? {type, value:
|
|
479
|
-
: {type, value: new Date(
|
|
582
|
+
? {type, value: date.getTime()}
|
|
583
|
+
: {type, value: new Date(date.getTime())};
|
|
480
584
|
}
|
|
481
585
|
return {type, invalid: true, message: 'Not a valid date'};
|
|
482
586
|
// Falls through
|
|
483
587
|
} case 'invalid': default: {
|
|
484
588
|
// Other `typeof` types which are not valid keys:
|
|
485
|
-
// 'undefined', 'boolean', 'object' (including `null`), 'symbol', 'function
|
|
589
|
+
// 'undefined', 'boolean', 'object' (including `null`), 'symbol', 'function'
|
|
486
590
|
const type = input === null ? 'null' : typeof input; // Convert `null` for convenience of consumers in reporting errors
|
|
487
591
|
return {type, invalid: true, message: 'Not a valid key; type ' + type};
|
|
488
592
|
}
|
|
489
593
|
}
|
|
490
594
|
}
|
|
491
595
|
|
|
492
|
-
/**
|
|
493
|
-
* @typedef {*} module:Key.Key
|
|
494
|
-
* @todo Specify possible value more precisely
|
|
495
|
-
*/
|
|
496
|
-
|
|
497
596
|
/**
|
|
498
597
|
*
|
|
499
|
-
* @param {
|
|
500
|
-
* @param {boolean} fullKeys
|
|
501
|
-
* @returns {
|
|
598
|
+
* @param {Key} key
|
|
599
|
+
* @param {boolean} [fullKeys]
|
|
600
|
+
* @returns {KeyValueObject}
|
|
502
601
|
* @todo Document other allowable `key`?
|
|
503
602
|
*/
|
|
504
603
|
function convertValueToMultiEntryKeyDecoded (key, fullKeys) {
|
|
@@ -507,10 +606,10 @@ function convertValueToMultiEntryKeyDecoded (key, fullKeys) {
|
|
|
507
606
|
|
|
508
607
|
/**
|
|
509
608
|
* An internal utility.
|
|
510
|
-
* @param input
|
|
511
|
-
* @param {
|
|
609
|
+
* @param {Value} input
|
|
610
|
+
* @param {Value[]|null|undefined} [seen]
|
|
512
611
|
* @throws {DOMException} `DataError`
|
|
513
|
-
* @returns {
|
|
612
|
+
* @returns {KeyValueObject}
|
|
514
613
|
*/
|
|
515
614
|
function convertValueToKeyRethrowingAndIfInvalid (input, seen) {
|
|
516
615
|
const key = convertValueToKey(input, seen);
|
|
@@ -522,10 +621,10 @@ function convertValueToKeyRethrowingAndIfInvalid (input, seen) {
|
|
|
522
621
|
|
|
523
622
|
/**
|
|
524
623
|
*
|
|
525
|
-
* @param value
|
|
526
|
-
* @param keyPath
|
|
624
|
+
* @param {Value} value
|
|
625
|
+
* @param {KeyPath} keyPath
|
|
527
626
|
* @param {boolean} multiEntry
|
|
528
|
-
* @returns {
|
|
627
|
+
* @returns {KeyValueObject|KeyPathEvaluateValue}
|
|
529
628
|
* @todo Document other possible return?
|
|
530
629
|
*/
|
|
531
630
|
function extractKeyFromValueUsingKeyPath (value, keyPath, multiEntry) {
|
|
@@ -533,10 +632,10 @@ function extractKeyFromValueUsingKeyPath (value, keyPath, multiEntry) {
|
|
|
533
632
|
}
|
|
534
633
|
/**
|
|
535
634
|
* Not currently in use.
|
|
536
|
-
* @param value
|
|
537
|
-
* @param keyPath
|
|
635
|
+
* @param {Value} value
|
|
636
|
+
* @param {KeyPath} keyPath
|
|
538
637
|
* @param {boolean} multiEntry
|
|
539
|
-
* @returns {
|
|
638
|
+
* @returns {KeyPathEvaluateValue}
|
|
540
639
|
*/
|
|
541
640
|
function evaluateKeyPathOnValue (value, keyPath, multiEntry) {
|
|
542
641
|
return evaluateKeyPathOnValueToDecodedValue(value, keyPath, multiEntry, true);
|
|
@@ -545,11 +644,11 @@ function evaluateKeyPathOnValue (value, keyPath, multiEntry) {
|
|
|
545
644
|
/**
|
|
546
645
|
* May throw, return `{failure: true}` (e.g., non-object on keyPath resolution)
|
|
547
646
|
* or `{invalid: true}` (e.g., `NaN`).
|
|
548
|
-
* @param value
|
|
549
|
-
* @param keyPath
|
|
550
|
-
* @param {boolean} multiEntry
|
|
551
|
-
* @param {boolean} fullKeys
|
|
552
|
-
* @returns {
|
|
647
|
+
* @param {Value} value
|
|
648
|
+
* @param {KeyPath} keyPath
|
|
649
|
+
* @param {boolean} [multiEntry]
|
|
650
|
+
* @param {boolean} [fullKeys]
|
|
651
|
+
* @returns {KeyValueObject|KeyPathEvaluateValue}
|
|
553
652
|
* @todo Document other possible return?
|
|
554
653
|
*/
|
|
555
654
|
function extractKeyValueDecodedFromValueUsingKeyPath (value, keyPath, multiEntry, fullKeys) {
|
|
@@ -564,26 +663,37 @@ function extractKeyValueDecodedFromValueUsingKeyPath (value, keyPath, multiEntry
|
|
|
564
663
|
}
|
|
565
664
|
|
|
566
665
|
/**
|
|
567
|
-
*
|
|
568
|
-
* @
|
|
569
|
-
|
|
666
|
+
* Unused?
|
|
667
|
+
* @typedef {object} KeyPathEvaluateFailure
|
|
668
|
+
* @property {boolean} failure
|
|
669
|
+
*/
|
|
570
670
|
|
|
571
671
|
/**
|
|
572
|
-
* @typedef {
|
|
573
|
-
|
|
574
|
-
|
|
672
|
+
* @typedef {KeyPathEvaluateValueValue[]} KeyPathEvaluateValueValueArray
|
|
673
|
+
*/
|
|
674
|
+
|
|
675
|
+
/**
|
|
676
|
+
* @typedef {undefined|number|string|Date|object|KeyPathEvaluateValueValueArray} KeyPathEvaluateValueValue
|
|
677
|
+
*/
|
|
678
|
+
|
|
679
|
+
/**
|
|
680
|
+
* @typedef {object} KeyPathEvaluateValue
|
|
681
|
+
* @property {KeyPathEvaluateValueValue} [value]
|
|
682
|
+
* @property {boolean} [failure]
|
|
683
|
+
*/
|
|
575
684
|
|
|
576
685
|
/**
|
|
577
686
|
* Returns the value of an inline key based on a key path (wrapped in an
|
|
578
687
|
* object with key `value`) or `{failure: true}`
|
|
579
|
-
* @param {
|
|
580
|
-
* @param {
|
|
581
|
-
* @param {boolean} multiEntry
|
|
688
|
+
* @param {Value} value
|
|
689
|
+
* @param {KeyPath} keyPath
|
|
690
|
+
* @param {boolean} [multiEntry]
|
|
582
691
|
* @param {boolean} [fullKeys]
|
|
583
|
-
* @returns {
|
|
692
|
+
* @returns {KeyPathEvaluateValue}
|
|
584
693
|
*/
|
|
585
694
|
function evaluateKeyPathOnValueToDecodedValue (value, keyPath, multiEntry, fullKeys) {
|
|
586
695
|
if (Array.isArray(keyPath)) {
|
|
696
|
+
/** @type {KeyPathEvaluateValueValueArray} */
|
|
587
697
|
const result = [];
|
|
588
698
|
return keyPath.some((item) => {
|
|
589
699
|
const key = evaluateKeyPathOnValueToDecodedValue(value, item, multiEntry, fullKeys);
|
|
@@ -600,7 +710,7 @@ function evaluateKeyPathOnValueToDecodedValue (value, keyPath, multiEntry, fullK
|
|
|
600
710
|
return {value};
|
|
601
711
|
}
|
|
602
712
|
const identifiers = keyPath.split('.');
|
|
603
|
-
return identifiers.some((idntfr
|
|
713
|
+
return identifiers.some((idntfr) => {
|
|
604
714
|
if (idntfr === 'length' && (
|
|
605
715
|
typeof value === 'string' || Array.isArray(value)
|
|
606
716
|
)) {
|
|
@@ -608,22 +718,24 @@ function evaluateKeyPathOnValueToDecodedValue (value, keyPath, multiEntry, fullK
|
|
|
608
718
|
} else if (util.isBlob(value)) {
|
|
609
719
|
switch (idntfr) {
|
|
610
720
|
case 'size': case 'type':
|
|
611
|
-
value = value[idntfr];
|
|
721
|
+
value = /** @type {Blob} */ (value)[idntfr];
|
|
612
722
|
break;
|
|
613
723
|
}
|
|
614
724
|
} else if (util.isFile(value)) {
|
|
615
725
|
switch (idntfr) {
|
|
616
726
|
case 'name': case 'lastModified':
|
|
617
|
-
value = value[idntfr];
|
|
727
|
+
value = /** @type {File} */ (value)[idntfr];
|
|
618
728
|
break;
|
|
619
729
|
case 'lastModifiedDate':
|
|
620
|
-
value = new Date(value.lastModified);
|
|
730
|
+
value = new Date(/** @type {File} */ (value).lastModified);
|
|
621
731
|
break;
|
|
622
732
|
}
|
|
623
|
-
} else if (!util.isObj(value) || !Object.
|
|
733
|
+
} else if (!util.isObj(value) || !Object.hasOwn(value, idntfr)) {
|
|
624
734
|
return true;
|
|
625
735
|
} else {
|
|
626
|
-
value =
|
|
736
|
+
value = /** @type {{[key: string]: KeyPathEvaluateValueValue}} */ (
|
|
737
|
+
value
|
|
738
|
+
)[idntfr];
|
|
627
739
|
return value === undefined;
|
|
628
740
|
}
|
|
629
741
|
return false;
|
|
@@ -634,8 +746,8 @@ function evaluateKeyPathOnValueToDecodedValue (value, keyPath, multiEntry, fullK
|
|
|
634
746
|
|
|
635
747
|
/**
|
|
636
748
|
* Sets the inline key value.
|
|
637
|
-
* @param {
|
|
638
|
-
* @param {
|
|
749
|
+
* @param {{[key: string]: AnyValue}} value
|
|
750
|
+
* @param {Key} key
|
|
639
751
|
* @param {string} keyPath
|
|
640
752
|
* @returns {void}
|
|
641
753
|
*/
|
|
@@ -643,19 +755,19 @@ function injectKeyIntoValueUsingKeyPath (value, key, keyPath) {
|
|
|
643
755
|
const identifiers = keyPath.split('.');
|
|
644
756
|
const last = identifiers.pop();
|
|
645
757
|
identifiers.forEach((identifier) => {
|
|
646
|
-
const hop = Object.
|
|
758
|
+
const hop = Object.hasOwn(value, identifier);
|
|
647
759
|
if (!hop) {
|
|
648
760
|
value[identifier] = {};
|
|
649
761
|
}
|
|
650
762
|
value = value[identifier];
|
|
651
763
|
});
|
|
652
|
-
value[last] = key; // key is already a `keyValue` in our processing so no need to convert
|
|
764
|
+
value[/** @type {string} */ (last)] = key; // key is already a `keyValue` in our processing so no need to convert
|
|
653
765
|
}
|
|
654
766
|
|
|
655
767
|
/**
|
|
656
768
|
*
|
|
657
|
-
* @param value
|
|
658
|
-
* @param keyPath
|
|
769
|
+
* @param {Value} value
|
|
770
|
+
* @param {string} keyPath
|
|
659
771
|
* @see https://github.com/w3c/IndexedDB/pull/146
|
|
660
772
|
* @returns {boolean}
|
|
661
773
|
*/
|
|
@@ -666,20 +778,20 @@ function checkKeyCouldBeInjectedIntoValue (value, keyPath) {
|
|
|
666
778
|
if (!util.isObj(value)) {
|
|
667
779
|
return false;
|
|
668
780
|
}
|
|
669
|
-
const hop = Object.
|
|
781
|
+
const hop = Object.hasOwn(value, identifier);
|
|
670
782
|
if (!hop) {
|
|
671
783
|
return true;
|
|
672
784
|
}
|
|
673
|
-
value = value[identifier];
|
|
785
|
+
value = /** @type {{[key: string]: Value}} */ (value)[identifier];
|
|
674
786
|
}
|
|
675
787
|
return util.isObj(value);
|
|
676
788
|
}
|
|
677
789
|
|
|
678
790
|
/**
|
|
679
791
|
*
|
|
680
|
-
* @param {
|
|
681
|
-
* @param {IDBKeyRange} range
|
|
682
|
-
* @param {boolean} checkCached
|
|
792
|
+
* @param {Key} key
|
|
793
|
+
* @param {import('./IDBKeyRange.js').IDBKeyRangeFull} range
|
|
794
|
+
* @param {boolean} [checkCached]
|
|
683
795
|
* @returns {boolean}
|
|
684
796
|
*/
|
|
685
797
|
function isKeyInRange (key, range, checkCached) {
|
|
@@ -689,21 +801,25 @@ function isKeyInRange (key, range, checkCached) {
|
|
|
689
801
|
const lower = checkCached ? range.__lowerCached : encode(range.lower, true);
|
|
690
802
|
const upper = checkCached ? range.__upperCached : encode(range.upper, true);
|
|
691
803
|
|
|
692
|
-
if (
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
804
|
+
if (!lowerMatch && (
|
|
805
|
+
(range.lowerOpen &&
|
|
806
|
+
encodedKey !== null && lower !== null && encodedKey > lower) ||
|
|
807
|
+
(!range.lowerOpen && (
|
|
808
|
+
(!encodedKey && !lower) ||
|
|
809
|
+
(encodedKey !== null && lower !== null && encodedKey >= lower))
|
|
810
|
+
)
|
|
811
|
+
)) {
|
|
812
|
+
lowerMatch = true;
|
|
699
813
|
}
|
|
700
|
-
if (
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
814
|
+
if (!upperMatch && (
|
|
815
|
+
(range.upperOpen &&
|
|
816
|
+
encodedKey !== null && upper !== null && encodedKey < upper) ||
|
|
817
|
+
(!range.upperOpen && (
|
|
818
|
+
(!encodedKey && !upper) ||
|
|
819
|
+
(encodedKey !== null && upper !== null && encodedKey <= upper))
|
|
820
|
+
)
|
|
821
|
+
)) {
|
|
822
|
+
upperMatch = true;
|
|
707
823
|
}
|
|
708
824
|
|
|
709
825
|
return lowerMatch && upperMatch;
|
|
@@ -726,9 +842,9 @@ function isMultiEntryMatch (encodedEntry, encodedKey) {
|
|
|
726
842
|
|
|
727
843
|
/**
|
|
728
844
|
*
|
|
729
|
-
* @param {
|
|
730
|
-
* @param {IDBKeyRange} range
|
|
731
|
-
* @returns {
|
|
845
|
+
* @param {Key} keyEntry
|
|
846
|
+
* @param {import('./IDBKeyRange.js').IDBKeyRangeFull|undefined} range
|
|
847
|
+
* @returns {Key[]}
|
|
732
848
|
*/
|
|
733
849
|
function findMultiEntryMatches (keyEntry, range) {
|
|
734
850
|
const matches = [];
|
|
@@ -760,15 +876,11 @@ function findMultiEntryMatches (keyEntry, range) {
|
|
|
760
876
|
return matches;
|
|
761
877
|
}
|
|
762
878
|
|
|
763
|
-
/**
|
|
764
|
-
* @typedef {number|string|Date|ArrayBuffer|module:Key.ValueTypes[]} module:Key.ValueTypes
|
|
765
|
-
*/
|
|
766
|
-
|
|
767
879
|
/**
|
|
768
880
|
* Not currently in use but keeping for spec parity.
|
|
769
|
-
* @param {
|
|
881
|
+
* @param {Key} key
|
|
770
882
|
* @throws {Error} Upon a "bad key"
|
|
771
|
-
* @returns {
|
|
883
|
+
* @returns {ValueType}
|
|
772
884
|
*/
|
|
773
885
|
function convertKeyToValue (key) {
|
|
774
886
|
const {type, value} = key;
|
|
@@ -801,8 +913,8 @@ function convertKeyToValue (key) {
|
|
|
801
913
|
|
|
802
914
|
/**
|
|
803
915
|
*
|
|
804
|
-
* @param {
|
|
805
|
-
* @param {boolean} inArray
|
|
916
|
+
* @param {Key} key
|
|
917
|
+
* @param {boolean} [inArray]
|
|
806
918
|
* @returns {string|null}
|
|
807
919
|
*/
|
|
808
920
|
function encode (key, inArray) {
|
|
@@ -811,15 +923,16 @@ function encode (key, inArray) {
|
|
|
811
923
|
return null;
|
|
812
924
|
}
|
|
813
925
|
// array, date, number, string, binary (should already have detected "invalid")
|
|
926
|
+
// @ts-expect-error Argument may be ignored
|
|
814
927
|
return types[getKeyType(key)].encode(key, inArray);
|
|
815
928
|
}
|
|
816
929
|
|
|
817
930
|
/**
|
|
818
931
|
*
|
|
819
|
-
* @param {
|
|
820
|
-
* @param {boolean} inArray
|
|
932
|
+
* @param {Key} key
|
|
933
|
+
* @param {boolean} [inArray]
|
|
821
934
|
* @throws {Error} Invalid number
|
|
822
|
-
* @returns {undefined|
|
|
935
|
+
* @returns {undefined|ValueType}
|
|
823
936
|
*/
|
|
824
937
|
function decode (key, inArray) {
|
|
825
938
|
if (typeof key !== 'string') {
|
|
@@ -830,9 +943,9 @@ function decode (key, inArray) {
|
|
|
830
943
|
|
|
831
944
|
/**
|
|
832
945
|
*
|
|
833
|
-
* @param {
|
|
834
|
-
* @param {boolean} inArray
|
|
835
|
-
* @returns {undefined|
|
|
946
|
+
* @param {Key} key
|
|
947
|
+
* @param {boolean} [inArray]
|
|
948
|
+
* @returns {undefined|ValueType}
|
|
836
949
|
*/
|
|
837
950
|
function roundTrip (key, inArray) {
|
|
838
951
|
return decode(encode(key, inArray), inArray);
|
|
@@ -841,30 +954,25 @@ function roundTrip (key, inArray) {
|
|
|
841
954
|
const MAX_ALLOWED_CURRENT_NUMBER = 9007199254740992; // 2 ^ 53 (Also equal to `Number.MAX_SAFE_INTEGER + 1`)
|
|
842
955
|
|
|
843
956
|
/**
|
|
844
|
-
* @
|
|
957
|
+
* @typedef {number} Integer
|
|
845
958
|
*/
|
|
846
959
|
|
|
847
|
-
/**
|
|
848
|
-
* @typedef {IDBObjectStore} IDBObjectStoreWithCurrentName
|
|
849
|
-
* @property {string} __currentName
|
|
850
|
-
*/
|
|
851
|
-
|
|
852
960
|
/**
|
|
853
961
|
* @callback CurrentNumberCallback
|
|
854
|
-
* @param {Integer} The current number
|
|
962
|
+
* @param {Integer} cn The current number
|
|
855
963
|
* @returns {void}
|
|
856
964
|
*/
|
|
857
965
|
|
|
858
966
|
/**
|
|
859
967
|
* @callback SQLFailureCallback
|
|
860
|
-
* @param {DOMException} exception
|
|
968
|
+
* @param {DOMException|Error} exception
|
|
861
969
|
* @returns {void}
|
|
862
970
|
*/
|
|
863
971
|
|
|
864
972
|
/**
|
|
865
973
|
*
|
|
866
|
-
* @param {
|
|
867
|
-
* @param {
|
|
974
|
+
* @param {SQLTransaction} tx
|
|
975
|
+
* @param {import('./IDBObjectStore.js').IDBObjectStoreFull} store
|
|
868
976
|
* @param {CurrentNumberCallback} func
|
|
869
977
|
* @param {SQLFailureCallback} sqlFailCb
|
|
870
978
|
* @returns {void}
|
|
@@ -884,13 +992,14 @@ function getCurrentNumber (tx, store, func, sqlFailCb) {
|
|
|
884
992
|
'Could not get the auto increment value for key',
|
|
885
993
|
error
|
|
886
994
|
));
|
|
995
|
+
return false;
|
|
887
996
|
});
|
|
888
997
|
}
|
|
889
998
|
|
|
890
999
|
/**
|
|
891
1000
|
*
|
|
892
|
-
* @param {
|
|
893
|
-
* @param {
|
|
1001
|
+
* @param {SQLTransaction} tx
|
|
1002
|
+
* @param {import('./IDBObjectStore.js').IDBObjectStoreFull} store
|
|
894
1003
|
* @param {Integer} num
|
|
895
1004
|
* @param {CurrentNumberCallback} successCb
|
|
896
1005
|
* @param {SQLFailureCallback} failCb
|
|
@@ -899,11 +1008,12 @@ function getCurrentNumber (tx, store, func, sqlFailCb) {
|
|
|
899
1008
|
function assignCurrentNumber (tx, store, num, successCb, failCb) {
|
|
900
1009
|
const sql = 'UPDATE __sys__ SET "currNum" = ? WHERE "name" = ?';
|
|
901
1010
|
const sqlValues = [num, util.escapeSQLiteStatement(store.__currentName)];
|
|
902
|
-
CFG.DEBUG
|
|
903
|
-
tx.executeSql(sql, sqlValues, function (
|
|
1011
|
+
if (CFG.DEBUG) { console.log(sql, sqlValues); }
|
|
1012
|
+
tx.executeSql(sql, sqlValues, function () {
|
|
904
1013
|
successCb(num);
|
|
905
1014
|
}, function (tx, err) {
|
|
906
1015
|
failCb(createDOMException('UnknownError', 'Could not set the auto increment value for key', err));
|
|
1016
|
+
return false;
|
|
907
1017
|
});
|
|
908
1018
|
}
|
|
909
1019
|
|
|
@@ -911,8 +1021,8 @@ function assignCurrentNumber (tx, store, num, successCb, failCb) {
|
|
|
911
1021
|
* Bump up the auto-inc counter if the key path-resolved value is valid
|
|
912
1022
|
* (greater than old value and >=1) OR if a manually passed in key is
|
|
913
1023
|
* valid (numeric and >= 1) and >= any primaryKey.
|
|
914
|
-
* @param {
|
|
915
|
-
* @param {
|
|
1024
|
+
* @param {SQLTransaction} tx
|
|
1025
|
+
* @param {import('./IDBObjectStore.js').IDBObjectStoreFull} store
|
|
916
1026
|
* @param {Integer} num
|
|
917
1027
|
* @param {CurrentNumberCallback} successCb
|
|
918
1028
|
* @param {SQLFailureCallback} failCb
|
|
@@ -935,8 +1045,8 @@ function setCurrentNumber (tx, store, num, successCb, failCb) {
|
|
|
935
1045
|
|
|
936
1046
|
/**
|
|
937
1047
|
*
|
|
938
|
-
* @param {
|
|
939
|
-
* @param {
|
|
1048
|
+
* @param {SQLTransaction} tx
|
|
1049
|
+
* @param {import('./IDBObjectStore.js').IDBObjectStoreFull} store
|
|
940
1050
|
* @param {KeyForStoreCallback} cb
|
|
941
1051
|
* @param {SQLFailureCallback} sqlFailCb
|
|
942
1052
|
* @returns {void}
|
|
@@ -965,10 +1075,10 @@ function generateKeyForStore (tx, store, cb, sqlFailCb) {
|
|
|
965
1075
|
// so we do not return a key
|
|
966
1076
|
/**
|
|
967
1077
|
*
|
|
968
|
-
* @param {
|
|
969
|
-
* @param {
|
|
970
|
-
* @param {
|
|
971
|
-
* @param {
|
|
1078
|
+
* @param {SQLTransaction} tx
|
|
1079
|
+
* @param {import('./IDBObjectStore.js').IDBObjectStoreFull} store
|
|
1080
|
+
* @param {import('./Key.js').Key} key
|
|
1081
|
+
* @param {(num?: Integer) => void} successCb
|
|
972
1082
|
* @param {SQLFailureCallback} sqlFailCb
|
|
973
1083
|
* @returns {void}
|
|
974
1084
|
*/
|