| 47 | * @hidden |
| 48 | */ |
| 49 | export 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 |
nothing calls this directly
no outgoing calls
no test coverage detected