| // simple shim for objectStore.getAll(), falling back to IDBCursor |
| function getAll(objectStore, keyRange, onSuccess) { |
| if (typeof objectStore.getAll === 'function') { |
| // use native getAll |
| objectStore.getAll(keyRange).onsuccess = onSuccess; |
| return; |
| } |
| // fall back to cursors |
| var values = []; |
| |
| function onCursor(e) { |
| var cursor = e.target.result; |
| if (cursor) { |
| values.push(cursor.value); |
| cursor.continue(); |
| } else { |
| onSuccess({ |
| target: { |
| result: values |
| } |
| }); |
| } |
| } |
| |
| objectStore.openCursor(keyRange).onsuccess = onCursor; |
| } |
| |
| export default getAll; |