lib0 0.2.55 → 0.2.56

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 CHANGED
@@ -759,12 +759,12 @@ In practice, when decoding several million small strings, the GC will kick in mo
759
759
  <b><code>indexeddb.put(store: IDBObjectStore, item: String | number | ArrayBuffer | Date | boolean, key: String | number | ArrayBuffer | Date | Array&lt;any&gt;)</code></b><br>
760
760
  <b><code>indexeddb.add(store: IDBObjectStore, item: String|number|ArrayBuffer|Date|boolean, key: String|number|ArrayBuffer|Date|Array.&lt;any&gt;): Promise&lt;any&gt;</code></b><br>
761
761
  <b><code>indexeddb.addAutoKey(store: IDBObjectStore, item: String|number|ArrayBuffer|Date): Promise&lt;number&gt;</code></b><br>
762
- <b><code>indexeddb.getAll(store: IDBObjectStore, range: IDBKeyRange): Promise&lt;Array&lt;any&gt;&gt;</code></b><br>
763
- <b><code>indexeddb.getAllKeys(store: IDBObjectStore, range: IDBKeyRange): Promise&lt;Array&lt;any&gt;&gt;</code></b><br>
762
+ <b><code>indexeddb.getAll(store: IDBObjectStore, range: IDBKeyRange, limit: number): Promise&lt;Array&lt;any&gt;&gt;</code></b><br>
763
+ <b><code>indexeddb.getAllKeys(store: IDBObjectStore, range: IDBKeyRange, limit: number): Promise&lt;Array&lt;any&gt;&gt;</code></b><br>
764
764
  <b><code>indexeddb.queryFirst(store: IDBObjectStore, query: IDBKeyRange|null, direction: 'next'|'prev'|'nextunique'|'prevunique'): Promise&lt;any&gt;</code></b><br>
765
765
  <b><code>indexeddb.getLastKey(store: IDBObjectStore, range: IDBKeyRange?): Promise&lt;any&gt;</code></b><br>
766
766
  <b><code>indexeddb.getFirstKey(store: IDBObjectStore, range: IDBKeyRange?): Promise&lt;any&gt;</code></b><br>
767
- <b><code>indexeddb.getAllKeysValues(store: IDBObjectStore, range: IDBKeyRange): Promise&lt;Array&lt;KeyValuePair&gt;&gt;</code></b><br>
767
+ <b><code>indexeddb.getAllKeysValues(store: IDBObjectStore, range: IDBKeyRange, limit: number): Promise&lt;Array&lt;KeyValuePair&gt;&gt;</code></b><br>
768
768
  <b><code>indexeddb.iterate(store: IDBObjectStore, keyrange: IDBKeyRange|null, f: function(any,any):void|boolean, direction: 'next'|'prev'|'nextunique'|'prevunique')</code></b><br>
769
769
  <dd><p>Iterate on keys and values</p></dd>
770
770
  <b><code>indexeddb.iterateKeys(store: IDBObjectStore, keyrange: IDBKeyRange|null, f: function(any):void|boolean, direction: 'next'|'prev'|'nextunique'|'prevunique')</code></b><br>
package/dist/index.cjs CHANGED
@@ -13,7 +13,7 @@ var environment = require('./environment-3c81ab2f.cjs');
13
13
  var error = require('./error-873c9cbf.cjs');
14
14
  var eventloop = require('./eventloop-c60b5658.cjs');
15
15
  var _function = require('./function-3410854f.cjs');
16
- var indexeddb = require('./indexeddb-5b4b0e13.cjs');
16
+ var indexeddb = require('./indexeddb-1aff4730.cjs');
17
17
  var iterator = require('./iterator-9fc627c1.cjs');
18
18
  var json = require('./json-092190a1.cjs');
19
19
  var logging = require('./logging-a2dc7e43.cjs');
@@ -145,19 +145,21 @@ const addAutoKey = (store, item) =>
145
145
  /**
146
146
  * @param {IDBObjectStore} store
147
147
  * @param {IDBKeyRange} [range]
148
+ * @param {number} [limit]
148
149
  * @return {Promise<Array<any>>}
149
150
  */
150
- const getAll = (store, range) =>
151
- rtop(store.getAll(range));
151
+ const getAll = (store, range, limit) =>
152
+ rtop(store.getAll(range, limit));
152
153
 
153
154
  /* istanbul ignore next */
154
155
  /**
155
156
  * @param {IDBObjectStore} store
156
157
  * @param {IDBKeyRange} [range]
158
+ * @param {number} [limit]
157
159
  * @return {Promise<Array<any>>}
158
160
  */
159
- const getAllKeys = (store, range) =>
160
- rtop(store.getAllKeys(range));
161
+ const getAllKeys = (store, range, limit) =>
162
+ rtop(store.getAllKeys(range, limit));
161
163
 
162
164
  /**
163
165
  * @param {IDBObjectStore} store
@@ -201,11 +203,12 @@ const getFirstKey = (store, range = null) => queryFirst(store, range, 'next');
201
203
  /**
202
204
  * @param {IDBObjectStore} store
203
205
  * @param {IDBKeyRange} [range]
206
+ * @param {number} [limit]
204
207
  * @return {Promise<Array<KeyValuePair>>}
205
208
  */
206
- const getAllKeysValues = (store, range) =>
209
+ const getAllKeysValues = (store, range, limit) =>
207
210
  // @ts-ignore
208
- promise.all([getAllKeys(store, range), getAll(store, range)]).then(([ks, vs]) => ks.map((k, i) => ({ k, v: vs[i] })));
211
+ promise.all([getAllKeys(store, range, limit), getAll(store, range, limit)]).then(([ks, vs]) => ks.map((k, i) => ({ k, v: vs[i] })));
209
212
 
210
213
  /* istanbul ignore next */
211
214
  /**
@@ -334,4 +337,4 @@ exports.put = put;
334
337
  exports.queryFirst = queryFirst;
335
338
  exports.rtop = rtop;
336
339
  exports.transact = transact;
337
- //# sourceMappingURL=indexeddb-5b4b0e13.cjs.map
340
+ //# sourceMappingURL=indexeddb-1aff4730.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"indexeddb-1aff4730.cjs","sources":["../indexeddb.js"],"sourcesContent":["/* eslint-env browser */\n\n/**\n * Helpers to work with IndexedDB.\n *\n * @module indexeddb\n */\n\nimport * as promise from './promise.js'\nimport * as error from './error.js'\n\n/* istanbul ignore next */\n/**\n * IDB Request to Promise transformer\n *\n * @param {IDBRequest} request\n * @return {Promise<any>}\n */\nexport const rtop = request => promise.create((resolve, reject) => {\n /* istanbul ignore next */\n // @ts-ignore\n request.onerror = event => reject(new Error(event.target.error))\n /* istanbul ignore next */\n // @ts-ignore\n request.onblocked = () => location.reload()\n // @ts-ignore\n request.onsuccess = event => resolve(event.target.result)\n})\n\n/* istanbul ignore next */\n/**\n * @param {string} name\n * @param {function(IDBDatabase):any} initDB Called when the database is first created\n * @return {Promise<IDBDatabase>}\n */\nexport const openDB = (name, initDB) => promise.create((resolve, reject) => {\n const request = indexedDB.open(name)\n /**\n * @param {any} event\n */\n request.onupgradeneeded = event => initDB(event.target.result)\n /* istanbul ignore next */\n /**\n * @param {any} event\n */\n request.onerror = event => reject(error.create(event.target.error))\n /* istanbul ignore next */\n request.onblocked = () => location.reload()\n /**\n * @param {any} event\n */\n request.onsuccess = event => {\n /**\n * @type {IDBDatabase}\n */\n const db = event.target.result\n /* istanbul ignore next */\n db.onversionchange = () => { db.close() }\n /* istanbul ignore if */\n if (typeof addEventListener !== 'undefined') {\n addEventListener('unload', () => db.close())\n }\n resolve(db)\n }\n})\n\n/* istanbul ignore next */\n/**\n * @param {string} name\n */\nexport const deleteDB = name => rtop(indexedDB.deleteDatabase(name))\n\n/* istanbul ignore next */\n/**\n * @param {IDBDatabase} db\n * @param {Array<Array<string>|Array<string|IDBObjectStoreParameters|undefined>>} definitions\n */\nexport const createStores = (db, definitions) => definitions.forEach(d =>\n // @ts-ignore\n db.createObjectStore.apply(db, d)\n)\n\n/**\n * @param {IDBDatabase} db\n * @param {Array<string>} stores\n * @param {\"readwrite\"|\"readonly\"} [access]\n * @return {Array<IDBObjectStore>}\n */\nexport const transact = (db, stores, access = 'readwrite') => {\n const transaction = db.transaction(stores, access)\n return stores.map(store => getStore(transaction, store))\n}\n\n/* istanbul ignore next */\n/**\n * @param {IDBObjectStore} store\n * @param {IDBKeyRange} [range]\n * @return {Promise<number>}\n */\nexport const count = (store, range) =>\n rtop(store.count(range))\n\n/* istanbul ignore next */\n/**\n * @param {IDBObjectStore} store\n * @param {String | number | ArrayBuffer | Date | Array<any> } key\n * @return {Promise<String | number | ArrayBuffer | Date | Array<any>>}\n */\nexport const get = (store, key) =>\n rtop(store.get(key))\n\n/* istanbul ignore next */\n/**\n * @param {IDBObjectStore} store\n * @param {String | number | ArrayBuffer | Date | IDBKeyRange | Array<any> } key\n */\nexport const del = (store, key) =>\n rtop(store.delete(key))\n\n/* istanbul ignore next */\n/**\n * @param {IDBObjectStore} store\n * @param {String | number | ArrayBuffer | Date | boolean} item\n * @param {String | number | ArrayBuffer | Date | Array<any>} [key]\n */\nexport const put = (store, item, key) =>\n rtop(store.put(item, key))\n\n/* istanbul ignore next */\n/**\n * @param {IDBObjectStore} store\n * @param {String | number | ArrayBuffer | Date | boolean} item\n * @param {String | number | ArrayBuffer | Date | Array<any>} key\n * @return {Promise<any>}\n */\nexport const add = (store, item, key) =>\n rtop(store.add(item, key))\n\n/* istanbul ignore next */\n/**\n * @param {IDBObjectStore} store\n * @param {String | number | ArrayBuffer | Date} item\n * @return {Promise<number>} Returns the generated key\n */\nexport const addAutoKey = (store, item) =>\n rtop(store.add(item))\n\n/* istanbul ignore next */\n/**\n * @param {IDBObjectStore} store\n * @param {IDBKeyRange} [range]\n * @param {number} [limit]\n * @return {Promise<Array<any>>}\n */\nexport const getAll = (store, range, limit) =>\n rtop(store.getAll(range, limit))\n\n/* istanbul ignore next */\n/**\n * @param {IDBObjectStore} store\n * @param {IDBKeyRange} [range]\n * @param {number} [limit]\n * @return {Promise<Array<any>>}\n */\nexport const getAllKeys = (store, range, limit) =>\n rtop(store.getAllKeys(range, limit))\n\n/**\n * @param {IDBObjectStore} store\n * @param {IDBKeyRange|null} query\n * @param {'next'|'prev'|'nextunique'|'prevunique'} direction\n * @return {Promise<any>}\n */\nexport const queryFirst = (store, query, direction) => {\n /**\n * @type {any}\n */\n let first = null\n return iterateKeys(store, query, key => {\n first = key\n return false\n }, direction).then(() => first)\n}\n\n/**\n * @param {IDBObjectStore} store\n * @param {IDBKeyRange?} [range]\n * @return {Promise<any>}\n */\nexport const getLastKey = (store, range = null) => queryFirst(store, range, 'prev')\n\n/**\n * @param {IDBObjectStore} store\n * @param {IDBKeyRange?} [range]\n * @return {Promise<any>}\n */\nexport const getFirstKey = (store, range = null) => queryFirst(store, range, 'next')\n\n/**\n * @typedef KeyValuePair\n * @type {Object}\n * @property {any} k key\n * @property {any} v Value\n */\n\n/* istanbul ignore next */\n/**\n * @param {IDBObjectStore} store\n * @param {IDBKeyRange} [range]\n * @param {number} [limit]\n * @return {Promise<Array<KeyValuePair>>}\n */\nexport const getAllKeysValues = (store, range, limit) =>\n // @ts-ignore\n promise.all([getAllKeys(store, range, limit), getAll(store, range, limit)]).then(([ks, vs]) => ks.map((k, i) => ({ k, v: vs[i] })))\n\n/* istanbul ignore next */\n/**\n * @param {any} request\n * @param {function(IDBCursorWithValue):void|boolean} f\n * @return {Promise<void>}\n */\nconst iterateOnRequest = (request, f) => promise.create((resolve, reject) => {\n /* istanbul ignore next */\n request.onerror = reject\n /**\n * @param {any} event\n */\n request.onsuccess = event => {\n const cursor = event.target.result\n if (cursor === null || f(cursor) === false) {\n return resolve()\n }\n cursor.continue()\n }\n})\n\n/* istanbul ignore next */\n/**\n * Iterate on keys and values\n * @param {IDBObjectStore} store\n * @param {IDBKeyRange|null} keyrange\n * @param {function(any,any):void|boolean} f Callback that receives (value, key)\n * @param {'next'|'prev'|'nextunique'|'prevunique'} direction\n */\nexport const iterate = (store, keyrange, f, direction = 'next') =>\n iterateOnRequest(store.openCursor(keyrange, direction), cursor => f(cursor.value, cursor.key))\n\n/* istanbul ignore next */\n/**\n * Iterate on the keys (no values)\n *\n * @param {IDBObjectStore} store\n * @param {IDBKeyRange|null} keyrange\n * @param {function(any):void|boolean} f callback that receives the key\n * @param {'next'|'prev'|'nextunique'|'prevunique'} direction\n */\nexport const iterateKeys = (store, keyrange, f, direction = 'next') =>\n iterateOnRequest(store.openKeyCursor(keyrange, direction), cursor => f(cursor.key))\n\n/* istanbul ignore next */\n/**\n * Open store from transaction\n * @param {IDBTransaction} t\n * @param {String} store\n * @returns {IDBObjectStore}\n */\nexport const getStore = (t, store) => t.objectStore(store)\n\n/* istanbul ignore next */\n/**\n * @param {any} lower\n * @param {any} upper\n * @param {boolean} lowerOpen\n * @param {boolean} upperOpen\n */\nexport const createIDBKeyRangeBound = (lower, upper, lowerOpen, upperOpen) => IDBKeyRange.bound(lower, upper, lowerOpen, upperOpen)\n\n/* istanbul ignore next */\n/**\n * @param {any} upper\n * @param {boolean} upperOpen\n */\nexport const createIDBKeyRangeUpperBound = (upper, upperOpen) => IDBKeyRange.upperBound(upper, upperOpen)\n\n/* istanbul ignore next */\n/**\n * @param {any} lower\n * @param {boolean} lowerOpen\n */\nexport const createIDBKeyRangeLowerBound = (lower, lowerOpen) => IDBKeyRange.lowerBound(lower, lowerOpen)\n"],"names":["promise.create","error.create","promise.all"],"mappings":";;;;;AAAA;AAUA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,IAAI,GAAG,OAAO,IAAIA,cAAc,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK;AACnE;AACA;AACA,EAAE,OAAO,CAAC,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAC;AAClE;AACA;AACA,EAAE,OAAO,CAAC,SAAS,GAAG,MAAM,QAAQ,CAAC,MAAM,GAAE;AAC7C;AACA,EAAE,OAAO,CAAC,SAAS,GAAG,KAAK,IAAI,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,EAAC;AAC3D,CAAC,EAAC;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,MAAM,GAAG,CAAC,IAAI,EAAE,MAAM,KAAKA,cAAc,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK;AAC5E,EAAE,MAAM,OAAO,GAAG,SAAS,CAAC,IAAI,CAAC,IAAI,EAAC;AACtC;AACA;AACA;AACA,EAAE,OAAO,CAAC,eAAe,GAAG,KAAK,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,EAAC;AAChE;AACA;AACA;AACA;AACA,EAAE,OAAO,CAAC,OAAO,GAAG,KAAK,IAAI,MAAM,CAACC,YAAY,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAC;AACrE;AACA,EAAE,OAAO,CAAC,SAAS,GAAG,MAAM,QAAQ,CAAC,MAAM,GAAE;AAC7C;AACA;AACA;AACA,EAAE,OAAO,CAAC,SAAS,GAAG,KAAK,IAAI;AAC/B;AACA;AACA;A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C,2BAA2B,GAAG,CAAC,KAAK,EAAE,SAAS,KAAK,WAAW,CAAC,UAAU,CAAC,KAAK,EAAE,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  require('./promise-1a9fe712.cjs');
6
6
  require('./error-873c9cbf.cjs');
7
- var indexeddb = require('./indexeddb-5b4b0e13.cjs');
7
+ var indexeddb = require('./indexeddb-1aff4730.cjs');
8
8
  require('./time-e00067da.cjs');
9
9
  require('./metric.cjs');
10
10
  require('./math-08e068f9.cjs');
@@ -9,12 +9,12 @@ export function del(store: IDBObjectStore, key: string | number | ArrayBuffer |
9
9
  export function put(store: IDBObjectStore, item: string | number | ArrayBuffer | Date | boolean, key?: string | number | any[] | Date | ArrayBuffer | undefined): Promise<any>;
10
10
  export function add(store: IDBObjectStore, item: string | number | ArrayBuffer | Date | boolean, key: string | number | ArrayBuffer | Date | Array<any>): Promise<any>;
11
11
  export function addAutoKey(store: IDBObjectStore, item: string | number | ArrayBuffer | Date): Promise<number>;
12
- export function getAll(store: IDBObjectStore, range?: IDBKeyRange | undefined): Promise<Array<any>>;
13
- export function getAllKeys(store: IDBObjectStore, range?: IDBKeyRange | undefined): Promise<Array<any>>;
12
+ export function getAll(store: IDBObjectStore, range?: IDBKeyRange | undefined, limit?: number | undefined): Promise<Array<any>>;
13
+ export function getAllKeys(store: IDBObjectStore, range?: IDBKeyRange | undefined, limit?: number | undefined): Promise<Array<any>>;
14
14
  export function queryFirst(store: IDBObjectStore, query: IDBKeyRange | null, direction: 'next' | 'prev' | 'nextunique' | 'prevunique'): Promise<any>;
15
15
  export function getLastKey(store: IDBObjectStore, range?: IDBKeyRange | null | undefined): Promise<any>;
16
16
  export function getFirstKey(store: IDBObjectStore, range?: IDBKeyRange | null | undefined): Promise<any>;
17
- export function getAllKeysValues(store: IDBObjectStore, range?: IDBKeyRange | undefined): Promise<Array<KeyValuePair>>;
17
+ export function getAllKeysValues(store: IDBObjectStore, range?: IDBKeyRange | undefined, limit?: number | undefined): Promise<Array<KeyValuePair>>;
18
18
  export function iterate(store: IDBObjectStore, keyrange: IDBKeyRange | null, f: (arg0: any, arg1: any) => void | boolean, direction?: 'next' | 'prev' | 'nextunique' | 'prevunique'): Promise<void>;
19
19
  export function iterateKeys(store: IDBObjectStore, keyrange: IDBKeyRange | null, f: (arg0: any) => void | boolean, direction?: 'next' | 'prev' | 'nextunique' | 'prevunique'): Promise<void>;
20
20
  export function getStore(t: IDBTransaction, store: string): IDBObjectStore;
@@ -1 +1 @@
1
- {"version":3,"file":"indexeddb.d.ts","sourceRoot":"","sources":["../indexeddb.js"],"names":[],"mappings":"AAkBO,8BAHI,UAAU,GACT,QAAQ,GAAG,CAAC,CAWtB;AAQK,6BAJI,MAAM,iBACG,WAAW,KAAE,GAAG,GACxB,QAAQ,WAAW,CAAC,CA+B9B;AAMK,+BAFI,MAAM,gBAEmD;AAO7D,iCAHI,WAAW,eACX,MAAM,MAAM,MAAM,CAAC,GAAC,MAAM,MAAM,GAAC,wBAAwB,GAAC,SAAS,CAAC,CAAC,QAK/E;AAQM,6BALI,WAAW,UACX,MAAM,MAAM,CAAC,kDAEZ,MAAM,cAAc,CAAC,CAKhC;AAQM,6BAJI,cAAc,oCAEb,QAAQ,MAAM,CAAC,CAGD;AAQnB,2BAJI,cAAc,OACd,SAAS,MAAM,GAAG,WAAW,GAAG,IAAI,GAAG,MAAM,GAAG,CAAC,GAChD,QAAQ,SAAS,MAAM,GAAG,WAAW,GAAG,IAAI,GAAG,MAAM,GAAG,CAAC,CAAC,CAGhD;AAOf,2BAHI,cAAc,OACd,SAAS,MAAM,GAAG,WAAW,GAAG,IAAI,GAAG,WAAW,GAAG,MAAM,GAAG,CAAC,gBAGjD;AAQlB,2BAJI,cAAc,QACd,SAAS,MAAM,GAAG,WAAW,GAAG,IAAI,GAAG,OAAO,gFAI7B;AASrB,2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AC,YAAY,GAAC,YAAY,GACtC,QAAQ,GAAG,CAAC,CAWvB;AAOM,kCAJI,cAAc,2CAEb,QAAQ,GAAG,CAAC,CAE2D;AAO5E,mCAJI,cAAc,2CAEb,QAAQ,GAAG,CAAC,CAE4D;AAgB7E,wCALI,cAAc,gEAGb,QAAQ,MAAM,YAAY,CAAC,CAAC,CAI6F;AA+B9H,+BALI,cAAc,YACd,WAAW,GAAC,IAAI,YACP,GAAG,QAAC,GAAG,KAAE,IAAI,GAAC,OAAO,cAC9B,MAAM,GAAC,MAAM,GAAC,YAAY,GAAC,YAAY,iBAG8C;AAWzF,mCALI,cAAc,YACd,WAAW,GAAC,IAAI,YACP,GAAG,KAAE,IAAI,GAAC,OAAO,cAC1B,MAAM,GAAC,MAAM,GAAC,YAAY,GAAC,YAAY,iBAGmC;AAS9E,4BAJI,cAAc,kBAEZ,cAAc,CAE+B;AASnD,8CALI,GAAG,SACH,GAAG,aACH,OAAO,aACP,OAAO,eAEiH;AAO5H,mDAHI,GAAG,aACH,OAAO,eAEuF;AAOlG,mDAHI,GAAG,aACH,OAAO,eAEuF;;;;;OAzF3F,GAAG;;;;OACH,GAAG"}
package/indexeddb.d.ts CHANGED
@@ -9,12 +9,12 @@ export function del(store: IDBObjectStore, key: string | number | ArrayBuffer |
9
9
  export function put(store: IDBObjectStore, item: string | number | ArrayBuffer | Date | boolean, key?: string | number | any[] | Date | ArrayBuffer | undefined): Promise<any>;
10
10
  export function add(store: IDBObjectStore, item: string | number | ArrayBuffer | Date | boolean, key: string | number | ArrayBuffer | Date | Array<any>): Promise<any>;
11
11
  export function addAutoKey(store: IDBObjectStore, item: string | number | ArrayBuffer | Date): Promise<number>;
12
- export function getAll(store: IDBObjectStore, range?: IDBKeyRange | undefined): Promise<Array<any>>;
13
- export function getAllKeys(store: IDBObjectStore, range?: IDBKeyRange | undefined): Promise<Array<any>>;
12
+ export function getAll(store: IDBObjectStore, range?: IDBKeyRange | undefined, limit?: number | undefined): Promise<Array<any>>;
13
+ export function getAllKeys(store: IDBObjectStore, range?: IDBKeyRange | undefined, limit?: number | undefined): Promise<Array<any>>;
14
14
  export function queryFirst(store: IDBObjectStore, query: IDBKeyRange | null, direction: 'next' | 'prev' | 'nextunique' | 'prevunique'): Promise<any>;
15
15
  export function getLastKey(store: IDBObjectStore, range?: IDBKeyRange | null | undefined): Promise<any>;
16
16
  export function getFirstKey(store: IDBObjectStore, range?: IDBKeyRange | null | undefined): Promise<any>;
17
- export function getAllKeysValues(store: IDBObjectStore, range?: IDBKeyRange | undefined): Promise<Array<KeyValuePair>>;
17
+ export function getAllKeysValues(store: IDBObjectStore, range?: IDBKeyRange | undefined, limit?: number | undefined): Promise<Array<KeyValuePair>>;
18
18
  export function iterate(store: IDBObjectStore, keyrange: IDBKeyRange | null, f: (arg0: any, arg1: any) => void | boolean, direction?: 'next' | 'prev' | 'nextunique' | 'prevunique'): Promise<void>;
19
19
  export function iterateKeys(store: IDBObjectStore, keyrange: IDBKeyRange | null, f: (arg0: any) => void | boolean, direction?: 'next' | 'prev' | 'nextunique' | 'prevunique'): Promise<void>;
20
20
  export function getStore(t: IDBTransaction, store: string): IDBObjectStore;
@@ -1 +1 @@
1
- {"version":3,"file":"indexeddb.d.ts","sourceRoot":"","sources":["indexeddb.js"],"names":[],"mappings":"AAkBO,8BAHI,UAAU,GACT,QAAQ,GAAG,CAAC,CAWtB;AAQK,6BAJI,MAAM,iBACG,WAAW,KAAE,GAAG,GACxB,QAAQ,WAAW,CAAC,CA+B9B;AAMK,+BAFI,MAAM,gBAEmD;AAO7D,iCAHI,WAAW,eACX,MAAM,MAAM,MAAM,CAAC,GAAC,MAAM,MAAM,GAAC,wBAAwB,GAAC,SAAS,CAAC,CAAC,QAK/E;AAQM,6BALI,WAAW,UACX,MAAM,MAAM,CAAC,kDAEZ,MAAM,cAAc,CAAC,CAKhC;AAQM,6BAJI,cAAc,oCAEb,QAAQ,MAAM,CAAC,CAGD;AAQnB,2BAJI,cAAc,OACd,SAAS,M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AAG,CAAC,GAChD,QAAQ,GAAG,CAAC,CAGI;AAQrB,kCAJI,cAAc,QACd,SAAS,MAAM,GAAG,WAAW,GAAG,IAAI,GACnC,QAAQ,MAAM,CAAC,CAGJ;AAShB,8BALI,cAAc,gEAGb,QAAQ,MAAM,GAAG,CAAC,CAAC,CAGG;AAS3B,kCALI,cAAc,gEAGb,QAAQ,MAAM,GAAG,CAAC,CAAC,CAGO;AAQ/B,kCALI,cAAc,SACd,WAAW,GAAC,IAAI,aAChB,MAAM,GAAC,MAAM,GAAC,YAAY,GAAC,YAAY,GACtC,QAAQ,GAAG,CAAC,CAWvB;AAOM,kCAJI,cAAc,2CAEb,QAAQ,GAAG,CAAC,CAE2D;AAO5E,mCAJI,cAAc,2CAEb,QAAQ,GAAG,CAAC,CAE4D;AAgB7E,wCALI,cAAc,gEAGb,QAAQ,MAAM,YAAY,CAAC,CAAC,CAI6F;AA+B9H,+BALI,cAAc,YACd,WAAW,GAAC,IAAI,YACP,GAAG,QAAC,GAAG,KAAE,IAAI,GAAC,OAAO,cAC9B,MAAM,GAAC,MAAM,GAAC,YAAY,GAAC,YAAY,iBAG8C;AAWzF,mCALI,cAAc,YACd,WAAW,GAAC,IAAI,YACP,GAAG,KAAE,IAAI,GAAC,OAAO,cAC1B,MAAM,GAAC,MAAM,GAAC,YAAY,GAAC,YAAY,iBAGmC;AAS9E,4BAJI,cAAc,kBAEZ,cAAc,CAE+B;AASnD,8CALI,GAAG,SACH,GAAG,aACH,OAAO,aACP,OAAO,eAEiH;AAO5H,mDAHI,GAAG,aACH,OAAO,eAEuF;AAOlG,mDAHI,GAAG,aACH,OAAO,eAEuF;;;;;OAzF3F,GAAG;;;;OACH,GAAG"}
package/indexeddb.js CHANGED
@@ -149,19 +149,21 @@ export const addAutoKey = (store, item) =>
149
149
  /**
150
150
  * @param {IDBObjectStore} store
151
151
  * @param {IDBKeyRange} [range]
152
+ * @param {number} [limit]
152
153
  * @return {Promise<Array<any>>}
153
154
  */
154
- export const getAll = (store, range) =>
155
- rtop(store.getAll(range))
155
+ export const getAll = (store, range, limit) =>
156
+ rtop(store.getAll(range, limit))
156
157
 
157
158
  /* istanbul ignore next */
158
159
  /**
159
160
  * @param {IDBObjectStore} store
160
161
  * @param {IDBKeyRange} [range]
162
+ * @param {number} [limit]
161
163
  * @return {Promise<Array<any>>}
162
164
  */
163
- export const getAllKeys = (store, range) =>
164
- rtop(store.getAllKeys(range))
165
+ export const getAllKeys = (store, range, limit) =>
166
+ rtop(store.getAllKeys(range, limit))
165
167
 
166
168
  /**
167
169
  * @param {IDBObjectStore} store
@@ -205,11 +207,12 @@ export const getFirstKey = (store, range = null) => queryFirst(store, range, 'ne
205
207
  /**
206
208
  * @param {IDBObjectStore} store
207
209
  * @param {IDBKeyRange} [range]
210
+ * @param {number} [limit]
208
211
  * @return {Promise<Array<KeyValuePair>>}
209
212
  */
210
- export const getAllKeysValues = (store, range) =>
213
+ export const getAllKeysValues = (store, range, limit) =>
211
214
  // @ts-ignore
212
- promise.all([getAllKeys(store, range), getAll(store, range)]).then(([ks, vs]) => ks.map((k, i) => ({ k, v: vs[i] })))
215
+ promise.all([getAllKeys(store, range, limit), getAll(store, range, limit)]).then(([ks, vs]) => ks.map((k, i) => ({ k, v: vs[i] })))
213
216
 
214
217
  /* istanbul ignore next */
215
218
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lib0",
3
- "version": "0.2.55",
3
+ "version": "0.2.56",
4
4
  "description": "",
5
5
  "sideEffects": false,
6
6
  "type": "module",
@@ -1 +0,0 @@
1
- {"version":3,"file":"indexeddb-5b4b0e13.cjs","sources":["../indexeddb.js"],"sourcesContent":["/* eslint-env browser */\n\n/**\n * Helpers to work with IndexedDB.\n *\n * @module indexeddb\n */\n\nimport * as promise from './promise.js'\nimport * as error from './error.js'\n\n/* istanbul ignore next */\n/**\n * IDB Request to Promise transformer\n *\n * @param {IDBRequest} request\n * @return {Promise<any>}\n */\nexport const rtop = request => promise.create((resolve, reject) => {\n /* istanbul ignore next */\n // @ts-ignore\n request.onerror = event => reject(new Error(event.target.error))\n /* istanbul ignore next */\n // @ts-ignore\n request.onblocked = () => location.reload()\n // @ts-ignore\n request.onsuccess = event => resolve(event.target.result)\n})\n\n/* istanbul ignore next */\n/**\n * @param {string} name\n * @param {function(IDBDatabase):any} initDB Called when the database is first created\n * @return {Promise<IDBDatabase>}\n */\nexport const openDB = (name, initDB) => promise.create((resolve, reject) => {\n const request = indexedDB.open(name)\n /**\n * @param {any} event\n */\n request.onupgradeneeded = event => initDB(event.target.result)\n /* istanbul ignore next */\n /**\n * @param {any} event\n */\n request.onerror = event => reject(error.create(event.target.error))\n /* istanbul ignore next */\n request.onblocked = () => location.reload()\n /**\n * @param {any} event\n */\n request.onsuccess = event => {\n /**\n * @type {IDBDatabase}\n */\n const db = event.target.result\n /* istanbul ignore next */\n db.onversionchange = () => { db.close() }\n /* istanbul ignore if */\n if (typeof addEventListener !== 'undefined') {\n addEventListener('unload', () => db.close())\n }\n resolve(db)\n }\n})\n\n/* istanbul ignore next */\n/**\n * @param {string} name\n */\nexport const deleteDB = name => rtop(indexedDB.deleteDatabase(name))\n\n/* istanbul ignore next */\n/**\n * @param {IDBDatabase} db\n * @param {Array<Array<string>|Array<string|IDBObjectStoreParameters|undefined>>} definitions\n */\nexport const createStores = (db, definitions) => definitions.forEach(d =>\n // @ts-ignore\n db.createObjectStore.apply(db, d)\n)\n\n/**\n * @param {IDBDatabase} db\n * @param {Array<string>} stores\n * @param {\"readwrite\"|\"readonly\"} [access]\n * @return {Array<IDBObjectStore>}\n */\nexport const transact = (db, stores, access = 'readwrite') => {\n const transaction = db.transaction(stores, access)\n return stores.map(store => getStore(transaction, store))\n}\n\n/* istanbul ignore next */\n/**\n * @param {IDBObjectStore} store\n * @param {IDBKeyRange} [range]\n * @return {Promise<number>}\n */\nexport const count = (store, range) =>\n rtop(store.count(range))\n\n/* istanbul ignore next */\n/**\n * @param {IDBObjectStore} store\n * @param {String | number | ArrayBuffer | Date | Array<any> } key\n * @return {Promise<String | number | ArrayBuffer | Date | Array<any>>}\n */\nexport const get = (store, key) =>\n rtop(store.get(key))\n\n/* istanbul ignore next */\n/**\n * @param {IDBObjectStore} store\n * @param {String | number | ArrayBuffer | Date | IDBKeyRange | Array<any> } key\n */\nexport const del = (store, key) =>\n rtop(store.delete(key))\n\n/* istanbul ignore next */\n/**\n * @param {IDBObjectStore} store\n * @param {String | number | ArrayBuffer | Date | boolean} item\n * @param {String | number | ArrayBuffer | Date | Array<any>} [key]\n */\nexport const put = (store, item, key) =>\n rtop(store.put(item, key))\n\n/* istanbul ignore next */\n/**\n * @param {IDBObjectStore} store\n * @param {String | number | ArrayBuffer | Date | boolean} item\n * @param {String | number | ArrayBuffer | Date | Array<any>} key\n * @return {Promise<any>}\n */\nexport const add = (store, item, key) =>\n rtop(store.add(item, key))\n\n/* istanbul ignore next */\n/**\n * @param {IDBObjectStore} store\n * @param {String | number | ArrayBuffer | Date} item\n * @return {Promise<number>} Returns the generated key\n */\nexport const addAutoKey = (store, item) =>\n rtop(store.add(item))\n\n/* istanbul ignore next */\n/**\n * @param {IDBObjectStore} store\n * @param {IDBKeyRange} [range]\n * @return {Promise<Array<any>>}\n */\nexport const getAll = (store, range) =>\n rtop(store.getAll(range))\n\n/* istanbul ignore next */\n/**\n * @param {IDBObjectStore} store\n * @param {IDBKeyRange} [range]\n * @return {Promise<Array<any>>}\n */\nexport const getAllKeys = (store, range) =>\n rtop(store.getAllKeys(range))\n\n/**\n * @param {IDBObjectStore} store\n * @param {IDBKeyRange|null} query\n * @param {'next'|'prev'|'nextunique'|'prevunique'} direction\n * @return {Promise<any>}\n */\nexport const queryFirst = (store, query, direction) => {\n /**\n * @type {any}\n */\n let first = null\n return iterateKeys(store, query, key => {\n first = key\n return false\n }, direction).then(() => first)\n}\n\n/**\n * @param {IDBObjectStore} store\n * @param {IDBKeyRange?} [range]\n * @return {Promise<any>}\n */\nexport const getLastKey = (store, range = null) => queryFirst(store, range, 'prev')\n\n/**\n * @param {IDBObjectStore} store\n * @param {IDBKeyRange?} [range]\n * @return {Promise<any>}\n */\nexport const getFirstKey = (store, range = null) => queryFirst(store, range, 'next')\n\n/**\n * @typedef KeyValuePair\n * @type {Object}\n * @property {any} k key\n * @property {any} v Value\n */\n\n/* istanbul ignore next */\n/**\n * @param {IDBObjectStore} store\n * @param {IDBKeyRange} [range]\n * @return {Promise<Array<KeyValuePair>>}\n */\nexport const getAllKeysValues = (store, range) =>\n // @ts-ignore\n promise.all([getAllKeys(store, range), getAll(store, range)]).then(([ks, vs]) => ks.map((k, i) => ({ k, v: vs[i] })))\n\n/* istanbul ignore next */\n/**\n * @param {any} request\n * @param {function(IDBCursorWithValue):void|boolean} f\n * @return {Promise<void>}\n */\nconst iterateOnRequest = (request, f) => promise.create((resolve, reject) => {\n /* istanbul ignore next */\n request.onerror = reject\n /**\n * @param {any} event\n */\n request.onsuccess = event => {\n const cursor = event.target.result\n if (cursor === null || f(cursor) === false) {\n return resolve()\n }\n cursor.continue()\n }\n})\n\n/* istanbul ignore next */\n/**\n * Iterate on keys and values\n * @param {IDBObjectStore} store\n * @param {IDBKeyRange|null} keyrange\n * @param {function(any,any):void|boolean} f Callback that receives (value, key)\n * @param {'next'|'prev'|'nextunique'|'prevunique'} direction\n */\nexport const iterate = (store, keyrange, f, direction = 'next') =>\n iterateOnRequest(store.openCursor(keyrange, direction), cursor => f(cursor.value, cursor.key))\n\n/* istanbul ignore next */\n/**\n * Iterate on the keys (no values)\n *\n * @param {IDBObjectStore} store\n * @param {IDBKeyRange|null} keyrange\n * @param {function(any):void|boolean} f callback that receives the key\n * @param {'next'|'prev'|'nextunique'|'prevunique'} direction\n */\nexport const iterateKeys = (store, keyrange, f, direction = 'next') =>\n iterateOnRequest(store.openKeyCursor(keyrange, direction), cursor => f(cursor.key))\n\n/* istanbul ignore next */\n/**\n * Open store from transaction\n * @param {IDBTransaction} t\n * @param {String} store\n * @returns {IDBObjectStore}\n */\nexport const getStore = (t, store) => t.objectStore(store)\n\n/* istanbul ignore next */\n/**\n * @param {any} lower\n * @param {any} upper\n * @param {boolean} lowerOpen\n * @param {boolean} upperOpen\n */\nexport const createIDBKeyRangeBound = (lower, upper, lowerOpen, upperOpen) => IDBKeyRange.bound(lower, upper, lowerOpen, upperOpen)\n\n/* istanbul ignore next */\n/**\n * @param {any} upper\n * @param {boolean} upperOpen\n */\nexport const createIDBKeyRangeUpperBound = (upper, upperOpen) => IDBKeyRange.upperBound(upper, upperOpen)\n\n/* istanbul ignore next */\n/**\n * @param {any} lower\n * @param {boolean} lowerOpen\n */\nexport const createIDBKeyRangeLowerBound = (lower, lowerOpen) => IDBKeyRange.lowerBound(lower, lowerOpen)\n"],"names":["promise.create","error.create","promise.all"],"mappings":";;;;;AAAA;AAUA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,IAAI,GAAG,OAAO,IAAIA,cAAc,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK;AACnE;AACA;AACA,EAAE,OAAO,CAAC,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAC;AAClE;AACA;AACA,EAAE,OAAO,CAAC,SAAS,GAAG,MAAM,QAAQ,CAAC,MAAM,GAAE;AAC7C;AACA,EAAE,OAAO,CAAC,SAAS,GAAG,KAAK,IAAI,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,EAAC;AAC3D,CAAC,EAAC;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,MAAM,GAAG,CAAC,IAAI,EAAE,MAAM,KAAKA,cAAc,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK;AAC5E,EAAE,MAAM,OAAO,GAAG,SAAS,CAAC,IAAI,CAAC,IAAI,EAAC;AACtC;AACA;AACA;AACA,EAAE,OAAO,CAAC,eAAe,GAAG,KAAK,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,C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