lib0 0.2.42 → 0.2.43
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 +78 -72
- package/bin/gendocs.js +1 -1
- package/component.d.ts +4 -1
- package/component.d.ts.map +1 -1
- package/component.js +4 -1
- package/dist/{broadcastchannel-8a61b21a.cjs → broadcastchannel-044f32d2.cjs} +2 -2
- package/dist/{broadcastchannel-8a61b21a.cjs.map → broadcastchannel-044f32d2.cjs.map} +1 -1
- package/dist/broadcastchannel.cjs +3 -3
- package/dist/{buffer-ac2cdedf.cjs → buffer-49880125.cjs} +2 -2
- package/dist/{buffer-ac2cdedf.cjs.map → buffer-49880125.cjs.map} +1 -1
- package/dist/buffer.cjs +2 -2
- package/dist/component.cjs +5 -2
- package/dist/component.cjs.map +1 -1
- package/dist/component.d.ts +4 -1
- package/dist/component.d.ts.map +1 -1
- package/dist/decoding.cjs +2 -2
- package/dist/encoding.cjs +2 -2
- package/dist/{error-55a9a8c8.cjs → error-873c9cbf.cjs} +4 -4
- package/dist/error-873c9cbf.cjs.map +1 -0
- package/dist/error.cjs +1 -1
- package/dist/error.d.ts.map +1 -1
- package/dist/index.cjs +7 -7
- package/dist/{indexeddb-44227700.cjs → indexeddb-5b4b0e13.cjs} +27 -25
- package/dist/indexeddb-5b4b0e13.cjs.map +1 -0
- package/dist/indexeddb.cjs +3 -3
- package/dist/indexeddb.d.ts +2 -2
- package/dist/indexeddb.d.ts.map +1 -1
- package/dist/isomorphic.cjs +2 -6
- package/dist/isomorphic.cjs.map +1 -1
- package/dist/{number-24f1eabe.cjs → number-e62129bc.cjs} +5 -2
- package/dist/number-e62129bc.cjs.map +1 -0
- package/dist/number.cjs +2 -1
- package/dist/number.cjs.map +1 -1
- package/dist/number.d.ts +1 -0
- package/dist/number.d.ts.map +1 -1
- package/dist/{prng-695120cc.cjs → prng-97174619.cjs} +2 -2
- package/dist/{prng-695120cc.cjs.map → prng-97174619.cjs.map} +1 -1
- package/dist/prng.cjs +3 -3
- package/dist/{promise-f0a086b2.cjs → promise-1a9fe712.cjs} +10 -1
- package/dist/{promise-f0a086b2.cjs.map → promise-1a9fe712.cjs.map} +1 -1
- package/dist/promise.cjs +2 -1
- package/dist/promise.cjs.map +1 -1
- package/dist/promise.d.ts +1 -0
- package/dist/promise.d.ts.map +1 -1
- package/dist/string.cjs +1 -3
- package/dist/string.cjs.map +1 -1
- package/dist/test.cjs +30 -25
- package/dist/test.cjs.map +1 -1
- package/dist/test.js +31 -26
- package/dist/test.js.map +1 -1
- package/dist/testing.cjs +8 -5
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.ts.map +1 -1
- package/dist/websocket.d.ts +1 -1
- package/dist/websocket.d.ts.map +1 -1
- package/error.d.ts.map +1 -1
- package/error.js +3 -3
- package/indexeddb.d.ts +2 -2
- package/indexeddb.d.ts.map +1 -1
- package/indexeddb.js +25 -23
- package/number.d.ts +1 -0
- package/number.d.ts.map +1 -1
- package/number.js +1 -0
- package/package.json +3 -3
- package/promise.d.ts +1 -0
- package/promise.d.ts.map +1 -1
- package/promise.js +7 -0
- package/testing.d.ts.map +1 -1
- package/testing.js +5 -2
- package/websocket.d.ts +1 -1
- package/websocket.d.ts.map +1 -1
- package/dist/error-55a9a8c8.cjs.map +0 -1
- package/dist/indexeddb-44227700.cjs.map +0 -1
- package/dist/number-24f1eabe.cjs.map +0 -1
|
@@ -48,6 +48,13 @@ const reject = reason => Promise.reject(reason);
|
|
|
48
48
|
*/
|
|
49
49
|
const resolve = res => Promise.resolve(res);
|
|
50
50
|
|
|
51
|
+
/**
|
|
52
|
+
* @template T
|
|
53
|
+
* @param {T} res
|
|
54
|
+
* @return {Promise<T>}
|
|
55
|
+
*/
|
|
56
|
+
const resolveWith = res => Promise.resolve(res);
|
|
57
|
+
|
|
51
58
|
/**
|
|
52
59
|
* @todo Next version, reorder parameters: check, [timeout, [intervalResolution]]
|
|
53
60
|
*
|
|
@@ -98,6 +105,7 @@ var promise = /*#__PURE__*/Object.freeze({
|
|
|
98
105
|
all: all,
|
|
99
106
|
reject: reject,
|
|
100
107
|
resolve: resolve,
|
|
108
|
+
resolveWith: resolveWith,
|
|
101
109
|
until: until,
|
|
102
110
|
wait: wait,
|
|
103
111
|
isPromise: isPromise
|
|
@@ -110,6 +118,7 @@ exports.isPromise = isPromise;
|
|
|
110
118
|
exports.promise = promise;
|
|
111
119
|
exports.reject = reject;
|
|
112
120
|
exports.resolve = resolve;
|
|
121
|
+
exports.resolveWith = resolveWith;
|
|
113
122
|
exports.until = until;
|
|
114
123
|
exports.wait = wait;
|
|
115
|
-
//# sourceMappingURL=promise-
|
|
124
|
+
//# sourceMappingURL=promise-1a9fe712.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"promise-
|
|
1
|
+
{"version":3,"file":"promise-1a9fe712.cjs","sources":["../promise.js"],"sourcesContent":["/**\n * Utility helpers to work with promises.\n *\n * @module promise\n */\n\nimport * as time from './time.js'\n\n/**\n * @template T\n * @callback PromiseResolve\n * @param {T|PromiseLike<T>} [result]\n */\n\n/**\n * @template T\n * @param {function(PromiseResolve<T>,function(Error):void):any} f\n * @return {Promise<T>}\n */\nexport const create = f => /** @type {Promise<T>} */ (new Promise(f))\n\n/**\n * @param {function(function():void,function(Error):void):void} f\n * @return {Promise<void>}\n */\nexport const createEmpty = f => new Promise(f)\n\n/**\n * `Promise.all` wait for all promises in the array to resolve and return the result\n * @template T\n * @param {Array<Promise<T>>} arrp\n * @return {Promise<Array<T>>}\n */\nexport const all = arrp => Promise.all(arrp)\n\n/**\n * @param {Error} [reason]\n * @return {Promise<never>}\n */\nexport const reject = reason => Promise.reject(reason)\n\n/**\n * @template T\n * @param {T|void} res\n * @return {Promise<T|void>}\n */\nexport const resolve = res => Promise.resolve(res)\n\n/**\n * @template T\n * @param {T} res\n * @return {Promise<T>}\n */\nexport const resolveWith = res => Promise.resolve(res)\n\n/**\n * @todo Next version, reorder parameters: check, [timeout, [intervalResolution]]\n *\n * @param {number} timeout\n * @param {function():boolean} check\n * @param {number} [intervalResolution]\n * @return {Promise<void>}\n */\nexport const until = (timeout, check, intervalResolution = 10) => create((resolve, reject) => {\n const startTime = time.getUnixTime()\n const hasTimeout = timeout > 0\n const untilInterval = () => {\n if (check()) {\n clearInterval(intervalHandle)\n resolve()\n } else if (hasTimeout) {\n /* istanbul ignore else */\n if (time.getUnixTime() - startTime > timeout) {\n clearInterval(intervalHandle)\n reject(new Error('Timeout'))\n }\n }\n }\n const intervalHandle = setInterval(untilInterval, intervalResolution)\n})\n\n/**\n * @param {number} timeout\n * @return {Promise<undefined>}\n */\nexport const wait = timeout => create((resolve, reject) => setTimeout(resolve, timeout))\n\n/**\n * Checks if an object is a promise using ducktyping.\n *\n * Promises are often polyfilled, so it makes sense to add some additional guarantees if the user of this\n * library has some insane environment where global Promise objects are overwritten.\n *\n * @param {any} p\n * @return {boolean}\n */\nexport const isPromise = p => p instanceof Promise || (p && p.then && p.catch && p.finally)\n"],"names":["time.getUnixTime"],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,MAAM,GAAG,CAAC,+BAA+B,IAAI,OAAO,CAAC,CAAC,CAAC,EAAC;AACrE;AACA;AACA;AACA;AACA;AACY,MAAC,WAAW,GAAG,CAAC,IAAI,IAAI,OAAO,CAAC,CAAC,EAAC;AAC9C;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,GAAG,GAAG,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,EAAC;AAC5C;AACA;AACA;AACA;AACA;AACY,MAAC,MAAM,GAAG,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAC;AACtD;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,OAAO,GAAG,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC,GAAG,EAAC;AAClD;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,WAAW,GAAG,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC,GAAG,EAAC;AACtD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,KAAK,GAAG,CAAC,OAAO,EAAE,KAAK,EAAE,kBAAkB,GAAG,EAAE,KAAK,MAAM,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK;AAC9F,EAAE,MAAM,SAAS,GAAGA,gBAAgB,GAAE;AACtC,EAAE,MAAM,UAAU,GAAG,OAAO,GAAG,EAAC;AAChC,EAAE,MAAM,aAAa,GAAG,MAAM;AAC9B,IAAI,IAAI,KAAK,EAAE,EAAE;AACjB,MAAM,aAAa,CAAC,cAAc,EAAC;AACnC,MAAM,OAAO,GAAE;AACf,KAAK,MAAM,IAAI,UAAU,EAAE;AAC3B;AACA,MAAM,IAAIA,gBAAgB,EAAE,GAAG,SAAS,GAAG,OAAO,EAAE;AACpD,QAAQ,aAAa,CAAC,cAAc,EAAC;AACrC,QAAQ,MAAM,CAAC,IAAI,KAAK,CAAC,SAAS,CAAC,EAAC;AACpC,OAAO;AACP,KAAK;AACL,IAAG;AACH,EAAE,MAAM,cAAc,GAAG,WAAW,CAAC,aAAa,EAAE,kBAAkB,EAAC;AACvE,CAAC,EAAC;AACF;AACA;AACA;AACA;AACA;AACY,MAAC,IAAI,GAAG,OAAO,IAAI,MAAM,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,EAAC;AACxF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,SAAS,GAAG,CAAC,IAAI,CAAC,YAAY,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/promise.cjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
require('./time-e00067da.cjs');
|
|
6
|
-
var promise = require('./promise-
|
|
6
|
+
var promise = require('./promise-1a9fe712.cjs');
|
|
7
7
|
require('./metric.cjs');
|
|
8
8
|
require('./math-08e068f9.cjs');
|
|
9
9
|
|
|
@@ -15,6 +15,7 @@ exports.createEmpty = promise.createEmpty;
|
|
|
15
15
|
exports.isPromise = promise.isPromise;
|
|
16
16
|
exports.reject = promise.reject;
|
|
17
17
|
exports.resolve = promise.resolve;
|
|
18
|
+
exports.resolveWith = promise.resolveWith;
|
|
18
19
|
exports.until = promise.until;
|
|
19
20
|
exports.wait = promise.wait;
|
|
20
21
|
//# sourceMappingURL=promise.cjs.map
|
package/dist/promise.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"promise.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"promise.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;"}
|
package/dist/promise.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export function createEmpty(f: (arg0: () => void, arg1: (arg0: Error) => void) =
|
|
|
3
3
|
export function all<T>(arrp: Promise<T>[]): Promise<T[]>;
|
|
4
4
|
export function reject(reason?: Error | undefined): Promise<never>;
|
|
5
5
|
export function resolve<T>(res: void | T): Promise<void | T>;
|
|
6
|
+
export function resolveWith<T>(res: T): Promise<T>;
|
|
6
7
|
export function until(timeout: number, check: () => boolean, intervalResolution?: number | undefined): Promise<void>;
|
|
7
8
|
export function wait(timeout: number): Promise<undefined>;
|
|
8
9
|
export function isPromise(p: any): boolean;
|
package/dist/promise.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"promise.d.ts","sourceRoot":"","sources":["../promise.js"],"names":[],"mappings":"AAmBO,oEAHwC,KAAK,KAAE,IAAI,KAAE,GAAG,cAGM;AAM9D,4CAHwB,IAAI,eAAU,KAAK,KAAE,IAAI,KAAE,IAAI,GAClD,QAAQ,IAAI,CAAC,CAEqB;AAQvC,yDAAqC;AAMrC,oDAFK,QAAQ,KAAK,CAAC,CAE4B;AAO/C,6DAA2C;
|
|
1
|
+
{"version":3,"file":"promise.d.ts","sourceRoot":"","sources":["../promise.js"],"names":[],"mappings":"AAmBO,oEAHwC,KAAK,KAAE,IAAI,KAAE,GAAG,cAGM;AAM9D,4CAHwB,IAAI,eAAU,KAAK,KAAE,IAAI,KAAE,IAAI,GAClD,QAAQ,IAAI,CAAC,CAEqB;AAQvC,yDAAqC;AAMrC,oDAFK,QAAQ,KAAK,CAAC,CAE4B;AAO/C,6DAA2C;AAO3C,mDAA+C;AAU/C,+BALI,MAAM,eACK,OAAO,4CAEjB,QAAQ,IAAI,CAAC,CAkBvB;AAMK,8BAHI,MAAM,GACL,QAAQ,SAAS,CAAC,CAE0D;AAWjF,6BAHI,GAAG,GACF,OAAO,CAEwE"}
|
package/dist/string.cjs
CHANGED
|
@@ -19,9 +19,7 @@ exports.trimLeft = string.trimLeft;
|
|
|
19
19
|
exports.utf8ByteLength = string.utf8ByteLength;
|
|
20
20
|
Object.defineProperty(exports, 'utf8TextDecoder', {
|
|
21
21
|
enumerable: true,
|
|
22
|
-
get: function () {
|
|
23
|
-
return string.utf8TextDecoder;
|
|
24
|
-
}
|
|
22
|
+
get: function () { return string.utf8TextDecoder; }
|
|
25
23
|
});
|
|
26
24
|
exports.utf8TextEncoder = string.utf8TextEncoder;
|
|
27
25
|
//# sourceMappingURL=string.cjs.map
|
package/dist/string.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"string.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/test.cjs
CHANGED
|
@@ -552,6 +552,14 @@ const mapToStyleString = m => map$3(m, (value, key) => `${key}:${value};`).join(
|
|
|
552
552
|
/* istanbul ignore next */
|
|
553
553
|
const appendChild = (parent, child) => parent.appendChild(child);
|
|
554
554
|
|
|
555
|
+
doc.ELEMENT_NODE;
|
|
556
|
+
doc.TEXT_NODE;
|
|
557
|
+
doc.CDATA_SECTION_NODE;
|
|
558
|
+
doc.COMMENT_NODE;
|
|
559
|
+
doc.DOCUMENT_NODE;
|
|
560
|
+
doc.DOCUMENT_TYPE_NODE;
|
|
561
|
+
doc.DOCUMENT_FRAGMENT_NODE;
|
|
562
|
+
|
|
555
563
|
/**
|
|
556
564
|
* JSON utility functions.
|
|
557
565
|
*
|
|
@@ -1459,12 +1467,6 @@ const simpleDiffString = (a, b) => {
|
|
|
1459
1467
|
}
|
|
1460
1468
|
};
|
|
1461
1469
|
|
|
1462
|
-
/**
|
|
1463
|
-
* @todo Remove in favor of simpleDiffString
|
|
1464
|
-
* @deprecated
|
|
1465
|
-
*/
|
|
1466
|
-
const simpleDiff = simpleDiffString;
|
|
1467
|
-
|
|
1468
1470
|
/**
|
|
1469
1471
|
* Create a diff between two arrays. This diff implementation is highly
|
|
1470
1472
|
* efficient, but not very sophisticated.
|
|
@@ -3757,6 +3759,9 @@ const run = async (moduleName, name, f, i, numberOfTests) => {
|
|
|
3757
3759
|
const times = [];
|
|
3758
3760
|
const start = isomorphic_js.performance.now();
|
|
3759
3761
|
let lastTime = start;
|
|
3762
|
+
/**
|
|
3763
|
+
* @type {any}
|
|
3764
|
+
*/
|
|
3760
3765
|
let err = null;
|
|
3761
3766
|
isomorphic_js.performance.mark(`${name}-start`);
|
|
3762
3767
|
do {
|
|
@@ -3977,7 +3982,7 @@ const compareArrays = (as, bs, m = 'Arrays match') => {
|
|
|
3977
3982
|
*/
|
|
3978
3983
|
const compareStrings = (a, b, m = 'Strings match') => {
|
|
3979
3984
|
if (a !== b) {
|
|
3980
|
-
const diff =
|
|
3985
|
+
const diff = simpleDiffString(a, b);
|
|
3981
3986
|
print(GREY, a.slice(0, diff.index), RED, a.slice(diff.index, diff.remove), GREEN, diff.insert, GREY, a.slice(diff.index + diff.remove));
|
|
3982
3987
|
fail(m);
|
|
3983
3988
|
}
|
|
@@ -5209,22 +5214,22 @@ var testing = /*#__PURE__*/Object.freeze({
|
|
|
5209
5214
|
* @module error
|
|
5210
5215
|
*/
|
|
5211
5216
|
|
|
5217
|
+
/* istanbul ignore next */
|
|
5212
5218
|
/**
|
|
5213
5219
|
* @param {string} s
|
|
5214
5220
|
* @return {Error}
|
|
5215
5221
|
*/
|
|
5216
|
-
/* istanbul ignore next */
|
|
5217
5222
|
const create$1 = s => new Error(s);
|
|
5218
5223
|
|
|
5219
5224
|
/* eslint-env browser */
|
|
5220
5225
|
|
|
5226
|
+
/* istanbul ignore next */
|
|
5221
5227
|
/**
|
|
5222
5228
|
* IDB Request to Promise transformer
|
|
5223
5229
|
*
|
|
5224
5230
|
* @param {IDBRequest} request
|
|
5225
5231
|
* @return {Promise<any>}
|
|
5226
5232
|
*/
|
|
5227
|
-
/* istanbul ignore next */
|
|
5228
5233
|
const rtop = request => create$2((resolve, reject) => {
|
|
5229
5234
|
/* istanbul ignore next */
|
|
5230
5235
|
// @ts-ignore
|
|
@@ -5236,12 +5241,12 @@ const rtop = request => create$2((resolve, reject) => {
|
|
|
5236
5241
|
request.onsuccess = event => resolve(event.target.result);
|
|
5237
5242
|
});
|
|
5238
5243
|
|
|
5244
|
+
/* istanbul ignore next */
|
|
5239
5245
|
/**
|
|
5240
5246
|
* @param {string} name
|
|
5241
5247
|
* @param {function(IDBDatabase):any} initDB Called when the database is first created
|
|
5242
5248
|
* @return {Promise<IDBDatabase>}
|
|
5243
5249
|
*/
|
|
5244
|
-
/* istanbul ignore next */
|
|
5245
5250
|
const openDB = (name, initDB) => create$2((resolve, reject) => {
|
|
5246
5251
|
const request = indexedDB.open(name);
|
|
5247
5252
|
/**
|
|
@@ -5273,82 +5278,82 @@ const openDB = (name, initDB) => create$2((resolve, reject) => {
|
|
|
5273
5278
|
};
|
|
5274
5279
|
});
|
|
5275
5280
|
|
|
5281
|
+
/* istanbul ignore next */
|
|
5276
5282
|
/**
|
|
5277
5283
|
* @param {string} name
|
|
5278
5284
|
*/
|
|
5279
|
-
/* istanbul ignore next */
|
|
5280
5285
|
const deleteDB = name => rtop(indexedDB.deleteDatabase(name));
|
|
5281
5286
|
|
|
5287
|
+
/* istanbul ignore next */
|
|
5282
5288
|
/**
|
|
5283
5289
|
* @param {IDBDatabase} db
|
|
5284
5290
|
* @param {Array<Array<string>|Array<string|IDBObjectStoreParameters|undefined>>} definitions
|
|
5285
5291
|
*/
|
|
5286
|
-
/* istanbul ignore next */
|
|
5287
5292
|
const createStores = (db, definitions) => definitions.forEach(d =>
|
|
5288
5293
|
// @ts-ignore
|
|
5289
5294
|
db.createObjectStore.apply(db, d)
|
|
5290
5295
|
);
|
|
5291
5296
|
|
|
5297
|
+
/* istanbul ignore next */
|
|
5292
5298
|
/**
|
|
5293
5299
|
* @param {IDBObjectStore} store
|
|
5294
5300
|
* @param {String | number | ArrayBuffer | Date | Array<any> } key
|
|
5295
5301
|
* @return {Promise<String | number | ArrayBuffer | Date | Array<any>>}
|
|
5296
5302
|
*/
|
|
5297
|
-
/* istanbul ignore next */
|
|
5298
5303
|
const get = (store, key) =>
|
|
5299
5304
|
rtop(store.get(key));
|
|
5300
5305
|
|
|
5306
|
+
/* istanbul ignore next */
|
|
5301
5307
|
/**
|
|
5302
5308
|
* @param {IDBObjectStore} store
|
|
5303
5309
|
* @param {String | number | ArrayBuffer | Date | IDBKeyRange | Array<any> } key
|
|
5304
5310
|
*/
|
|
5305
|
-
/* istanbul ignore next */
|
|
5306
5311
|
const del = (store, key) =>
|
|
5307
5312
|
rtop(store.delete(key));
|
|
5308
5313
|
|
|
5314
|
+
/* istanbul ignore next */
|
|
5309
5315
|
/**
|
|
5310
5316
|
* @param {IDBObjectStore} store
|
|
5311
5317
|
* @param {String | number | ArrayBuffer | Date | boolean} item
|
|
5312
5318
|
* @param {String | number | ArrayBuffer | Date | Array<any>} [key]
|
|
5313
5319
|
*/
|
|
5314
|
-
/* istanbul ignore next */
|
|
5315
5320
|
const put = (store, item, key) =>
|
|
5316
5321
|
rtop(store.put(item, key));
|
|
5317
5322
|
|
|
5323
|
+
/* istanbul ignore next */
|
|
5318
5324
|
/**
|
|
5319
5325
|
* @param {IDBObjectStore} store
|
|
5320
5326
|
* @param {String | number | ArrayBuffer | Date | boolean} item
|
|
5321
5327
|
* @param {String | number | ArrayBuffer | Date | Array<any>} key
|
|
5322
5328
|
* @return {Promise<any>}
|
|
5323
5329
|
*/
|
|
5324
|
-
/* istanbul ignore next */
|
|
5325
5330
|
const add = (store, item, key) =>
|
|
5326
5331
|
rtop(store.add(item, key));
|
|
5327
5332
|
|
|
5333
|
+
/* istanbul ignore next */
|
|
5328
5334
|
/**
|
|
5329
5335
|
* @param {IDBObjectStore} store
|
|
5330
5336
|
* @param {String | number | ArrayBuffer | Date} item
|
|
5331
5337
|
* @return {Promise<number>} Returns the generated key
|
|
5332
5338
|
*/
|
|
5333
|
-
/* istanbul ignore next */
|
|
5334
5339
|
const addAutoKey = (store, item) =>
|
|
5335
5340
|
rtop(store.add(item));
|
|
5336
5341
|
|
|
5342
|
+
/* istanbul ignore next */
|
|
5337
5343
|
/**
|
|
5338
5344
|
* @param {IDBObjectStore} store
|
|
5339
5345
|
* @param {IDBKeyRange} [range]
|
|
5340
5346
|
* @return {Promise<Array<any>>}
|
|
5341
5347
|
*/
|
|
5342
|
-
/* istanbul ignore next */
|
|
5343
5348
|
const getAll = (store, range) =>
|
|
5344
5349
|
rtop(store.getAll(range));
|
|
5345
5350
|
|
|
5351
|
+
/* istanbul ignore next */
|
|
5346
5352
|
/**
|
|
5347
5353
|
* @param {IDBObjectStore} store
|
|
5348
5354
|
* @param {IDBKeyRange} [range]
|
|
5349
5355
|
* @return {Promise<Array<any>>}
|
|
5350
5356
|
*/
|
|
5351
|
-
/* istanbul ignore next */
|
|
5352
5357
|
const getAllKeys = (store, range) =>
|
|
5353
5358
|
rtop(store.getAllKeys(range));
|
|
5354
5359
|
|
|
@@ -5359,22 +5364,22 @@ const getAllKeys = (store, range) =>
|
|
|
5359
5364
|
* @property {any} v Value
|
|
5360
5365
|
*/
|
|
5361
5366
|
|
|
5367
|
+
/* istanbul ignore next */
|
|
5362
5368
|
/**
|
|
5363
5369
|
* @param {IDBObjectStore} store
|
|
5364
5370
|
* @param {IDBKeyRange} [range]
|
|
5365
5371
|
* @return {Promise<Array<KeyValuePair>>}
|
|
5366
5372
|
*/
|
|
5367
|
-
/* istanbul ignore next */
|
|
5368
5373
|
const getAllKeysValues = (store, range) =>
|
|
5369
5374
|
// @ts-ignore
|
|
5370
5375
|
all([getAllKeys(store, range), getAll(store, range)]).then(([ks, vs]) => ks.map((k, i) => ({ k, v: vs[i] })));
|
|
5371
5376
|
|
|
5377
|
+
/* istanbul ignore next */
|
|
5372
5378
|
/**
|
|
5373
5379
|
* @param {any} request
|
|
5374
5380
|
* @param {function(IDBCursorWithValue):void|boolean} f
|
|
5375
5381
|
* @return {Promise<void>}
|
|
5376
5382
|
*/
|
|
5377
|
-
/* istanbul ignore next */
|
|
5378
5383
|
const iterateOnRequest = (request, f) => create$2((resolve, reject) => {
|
|
5379
5384
|
/* istanbul ignore next */
|
|
5380
5385
|
request.onerror = reject;
|
|
@@ -5390,6 +5395,7 @@ const iterateOnRequest = (request, f) => create$2((resolve, reject) => {
|
|
|
5390
5395
|
};
|
|
5391
5396
|
});
|
|
5392
5397
|
|
|
5398
|
+
/* istanbul ignore next */
|
|
5393
5399
|
/**
|
|
5394
5400
|
* Iterate on keys and values
|
|
5395
5401
|
* @param {IDBObjectStore} store
|
|
@@ -5397,10 +5403,10 @@ const iterateOnRequest = (request, f) => create$2((resolve, reject) => {
|
|
|
5397
5403
|
* @param {function(any,any):void|boolean} f Callback that receives (value, key)
|
|
5398
5404
|
* @param {'next'|'prev'|'nextunique'|'prevunique'} direction
|
|
5399
5405
|
*/
|
|
5400
|
-
/* istanbul ignore next */
|
|
5401
5406
|
const iterate = (store, keyrange, f, direction = 'next') =>
|
|
5402
5407
|
iterateOnRequest(store.openCursor(keyrange, direction), cursor => f(cursor.value, cursor.key));
|
|
5403
5408
|
|
|
5409
|
+
/* istanbul ignore next */
|
|
5404
5410
|
/**
|
|
5405
5411
|
* Iterate on the keys (no values)
|
|
5406
5412
|
*
|
|
@@ -5409,26 +5415,25 @@ const iterate = (store, keyrange, f, direction = 'next') =>
|
|
|
5409
5415
|
* @param {function(any):void|boolean} f callback that receives the key
|
|
5410
5416
|
* @param {'next'|'prev'|'nextunique'|'prevunique'} direction
|
|
5411
5417
|
*/
|
|
5412
|
-
/* istanbul ignore next */
|
|
5413
5418
|
const iterateKeys = (store, keyrange, f, direction = 'next') =>
|
|
5414
5419
|
iterateOnRequest(store.openKeyCursor(keyrange, direction), cursor => f(cursor.key));
|
|
5415
5420
|
|
|
5421
|
+
/* istanbul ignore next */
|
|
5416
5422
|
/**
|
|
5417
5423
|
* Open store from transaction
|
|
5418
5424
|
* @param {IDBTransaction} t
|
|
5419
5425
|
* @param {String} store
|
|
5420
5426
|
* @returns {IDBObjectStore}
|
|
5421
5427
|
*/
|
|
5422
|
-
/* istanbul ignore next */
|
|
5423
5428
|
const getStore$1 = (t, store) => t.objectStore(store);
|
|
5424
5429
|
|
|
5430
|
+
/* istanbul ignore next */
|
|
5425
5431
|
/**
|
|
5426
5432
|
* @param {any} lower
|
|
5427
5433
|
* @param {any} upper
|
|
5428
5434
|
* @param {boolean} lowerOpen
|
|
5429
5435
|
* @param {boolean} upperOpen
|
|
5430
5436
|
*/
|
|
5431
|
-
/* istanbul ignore next */
|
|
5432
5437
|
const createIDBKeyRangeBound = (lower, upper, lowerOpen, upperOpen) => IDBKeyRange.bound(lower, upper, lowerOpen, upperOpen);
|
|
5433
5438
|
|
|
5434
5439
|
/* istanbul ignore next */
|