MCPcopy Create free account
hub / github.com/heygen-com/hyperframes / withStore

Function withStore

packages/studio/src/utils/editHistoryStorage.ts:47–65  ·  view source on GitHub ↗
(
  mode: IDBTransactionMode,
  callback: (store: IDBObjectStore) => IDBRequest<T>,
)

Source from the content-addressed store, hash-verified

45}
46
47function withStore<T>(
48 mode: IDBTransactionMode,
49 callback: (store: IDBObjectStore) => IDBRequest<T>,
50): Promise<T> {
51 return openEditHistoryDb().then(
52 (db) =>
53 new Promise<T>((resolve, reject) => {
54 const tx = db.transaction(STORE_NAME, mode);
55 const request = callback(tx.objectStore(STORE_NAME));
56 request.onerror = () => reject(request.error ?? new Error("IndexedDB request failed"));
57 request.onsuccess = () => resolve(request.result);
58 tx.oncomplete = () => db.close();
59 tx.onerror = () => {
60 db.close();
61 reject(tx.error ?? new Error("IndexedDB transaction failed"));
62 };
63 }),
64 );
65}
66
67export function createIndexedDbEditHistoryStorage(): EditHistoryStorageAdapter {
68 return {

Callers

nothing calls this directly

Calls 3

openEditHistoryDbFunction · 0.85
resolveFunction · 0.85
closeMethod · 0.65

Tested by

no test coverage detected