MCPcopy
hub / github.com/jvilk/BrowserFS / IndexedDBROTransaction

Class IndexedDBROTransaction

src/backend/IndexedDB.ts:49–71  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

47 * @hidden
48 */
49export class IndexedDBROTransaction implements AsyncKeyValueROTransaction {
50 constructor(public tx: IDBTransaction, public store: IDBObjectStore) { }
51
52 public get(key: string, cb: BFSCallback<Buffer>): void {
53 try {
54 const r: IDBRequest = this.store.get(key);
55 r.onerror = onErrorHandler(cb);
56 r.onsuccess = (event) => {
57 // IDB returns the value 'undefined' when you try to get keys that
58 // don't exist. The caller expects this behavior.
59 const result: any = (<any> event.target).result;
60 if (result === undefined) {
61 cb(null, result);
62 } else {
63 // IDB data is stored as an ArrayBuffer
64 cb(null, arrayBuffer2Buffer(result));
65 }
66 };
67 } catch (e) {
68 cb(convertError(e));
69 }
70 }
71}
72
73/**
74 * @hidden

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected