use-idb-store
Version:
A React state hook that syncs state to IndexedDB for persistent, offline-friendly, and large-scale data storage.
21 lines (20 loc) • 1 kB
TypeScript
/**
* Converts an IndexedDB request into a Promise
* @template T The type of the result that will be returned by the IndexedDB request
* @param request The IndexedDB request to convert to a Promise
* @returns A Promise that resolves with the request result or rejects with an error message
*/
export declare function idbRequestToPromise<T>(request: IDBRequest): Promise<T>;
/**
* Safely executes an async operation with error handling
* @template T The type of the result that will be returned by the operation
* @param fn The async function to execute
* @returns A Promise that resolves with the result or null if an error occurs
*/
export declare function safeCall<T>(fn: () => Promise<T>): Promise<T | null>;
/**
* Safely executes an async operation that returns void with error handling
* @param fn The async function to execute
* @returns A Promise that resolves to void, silently handling any errors
*/
export declare function safeVoidCall(fn: () => Promise<unknown>): Promise<void>;