Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

lib0

Package Overview
Dependencies
Maintainers
1
Versions
113
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lib0 - npm Package Compare versions

Comparing version 0.2.5 to 0.2.6

.nyc_output/598731f2-a3ad-4949-9223-0a6f2fd43780.json

2

.nyc_output/processinfo/index.json

@@ -1,1 +0,1 @@

{"processes":{"b3c9a8e9-eb6e-4099-be96-bf94682c0c18":{"parent":null,"children":[]}},"files":{"/home/dmonad/ylabs/lib0/dist/test.cjs":["b3c9a8e9-eb6e-4099-be96-bf94682c0c18"]},"externalIds":{}}
{"processes":{"598731f2-a3ad-4949-9223-0a6f2fd43780":{"parent":null,"children":[]}},"files":{"/home/dmonad/ylabs/lib0/dist/test.cjs":["598731f2-a3ad-4949-9223-0a6f2fd43780"]},"externalIds":{}}

@@ -25,3 +25,3 @@ /* eslint-env browser */

* @param {string} name
* @param {Function} initDB Called when the database is first created
* @param {function(IDBDatabase):any} initDB Called when the database is first created
* @return {Promise<IDBDatabase>}

@@ -69,3 +69,3 @@ */

* @param {IDBDatabase} db
* @param {Array<[string,IDBObjectStoreParameters|undefined]>} definitions
* @param {Array<[string]|[string,IDBObjectStoreParameters|undefined]>} definitions
*/

@@ -78,3 +78,23 @@ /* istanbul ignore next */

/**
* @param {IDBDatabase} db
* @param {Array<string>} stores
* @param {"readwrite"|"readonly"} [access]
* @return {Array<IDBObjectStore>}
*/
export const transact = (db, stores, access = 'readwrite') => {
const transaction = db.transaction(stores, access)
return stores.map(store => getStore(transaction, store))
}
/**
* @param {IDBObjectStore} store
* @param {IDBKeyRange} [range]
* @return {Promise<number>}
*/
/* istanbul ignore next */
export const count = (store, range) =>
rtop(store.count(range))
/**
* @param {IDBObjectStore} store
* @param {String | number | ArrayBuffer | Date | Array<any> } key

@@ -126,2 +146,3 @@ * @return {Promise<String | number | ArrayBuffer | Date | Array<any>>}

* @param {IDBKeyRange} [range]
* @return {Promise<Array<any>>}
*/

@@ -135,2 +156,3 @@ /* istanbul ignore next */

* @param {IDBKeyRange} [range]
* @return {Promise<Array<any>>}
*/

@@ -142,2 +164,31 @@ /* istanbul ignore next */

/**
* @param {IDBObjectStore} store
* @param {IDBKeyRange|null} query
* @param {'next'|'prev'|'nextunique'|'prevunique'} direction
* @return {Promise<any>}
*/
export const queryFirst = (store, query, direction) => {
/**
* @type {any}
*/
let first = null
return iterateKeys(store, query, key => {
first = key
return false
}, direction).then(() => first)
}
/**
* @param {IDBObjectStore} store
* @return {Promise<any>}
*/
export const getLastKey = store => queryFirst(store, null, 'prev')
/**
* @param {IDBObjectStore} store
* @return {Promise<any>}
*/
export const getFirstKey = store => queryFirst(store, null, 'prev')
/**
* @typedef KeyValuePair

@@ -161,3 +212,3 @@ * @type {Object}

* @param {any} request
* @param {function(IDBCursorWithValue):void} f
* @param {function(IDBCursorWithValue):void|boolean} f
* @return {Promise<void>}

@@ -174,6 +225,5 @@ */

const cursor = event.target.result
if (cursor === null) {
if (cursor === null || f(cursor) === false) {
return resolve()
}
f(cursor)
cursor.continue()

@@ -187,7 +237,8 @@ }

* @param {IDBKeyRange|null} keyrange
* @param {function(any,any):void} f Callback that receives (value, key)
* @param {function(any,any):void|boolean} f Callback that receives (value, key)
* @param {'next'|'prev'|'nextunique'|'prevunique'} direction
*/
/* istanbul ignore next */
export const iterate = (store, keyrange, f) =>
iterateOnRequest(keyrange !== null ? store.openCursor(keyrange) : store.openCursor(), cursor => f(cursor.value, cursor.key))
export const iterate = (store, keyrange, f, direction = 'next') =>
iterateOnRequest(store.openCursor(keyrange, direction), cursor => f(cursor.value, cursor.key))

@@ -199,7 +250,8 @@ /**

* @param {IDBKeyRange|null} keyrange
* @param {function(any):void} f callback that receives the key
* @param {function(any):void|boolean} f callback that receives the key
* @param {'next'|'prev'|'nextunique'|'prevunique'} direction
*/
/* istanbul ignore next */
export const iterateKeys = (store, keyrange, f) =>
iterateOnRequest(keyrange !== null ? store.openKeyCursor(keyrange) : store.openKeyCursor(), cursor => f(cursor.key))
export const iterateKeys = (store, keyrange, f, direction = 'next') =>
iterateOnRequest(store.openKeyCursor(keyrange, direction), cursor => f(cursor.key))

@@ -206,0 +258,0 @@ /**

{
"name": "lib0",
"version": "0.2.5",
"version": "0.2.6",
"description": "",

@@ -5,0 +5,0 @@ "sideEffects": false,

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc