Skip to content

Instantly share code, notes, and snippets.

@Swivelgames
Last active December 2, 2016 06:46
Show Gist options
  • Save Swivelgames/bd0b55495c13b18624b59d3e9aaa4fa9 to your computer and use it in GitHub Desktop.
Save Swivelgames/bd0b55495c13b18624b59d3e9aaa4fa9 to your computer and use it in GitHub Desktop.
Get All BrowserFS IndexedDB Data
var res, ret;
db
.transaction(['browserfs'], 'readwrite')
.objectStore('browserfs')
.getAll()
.onsuccess =
(event) => {
res = event.target.result.map( (arrBuff) => {
if(arrBuff.byteLength !== 66) return new TextDecoder('utf-8').decode(new Uint8Array(arrBuff));
return {
'id' : new TextDecoder('utf-8').decode(new Uint8Array(arrBuff.slice(30))),
'size' : (new Uint32Array(arrBuff.slice(0,4)))[0],
'mode' : (new Uint16Array(arrBuff.slice(4,6)))[0],
'atime': (new Float64Array(arrBuff.slice(6,14)))[0],
'mtime': (new Float64Array(arrBuff.slice(14,22)))[0],
'ctime': (new Float64Array(arrBuff.slice(22,30)))[0]
};
});
};
db
.transaction(['browserfs'], 'readwrite')
.objectStore('browserfs')
.getAllKeys()
.onsuccess =
(event) => {
ret = {};
event.target.result.forEach( (v,i) => {
ret[v] = res[i];
});
};
@Swivelgames
Copy link
Author

After executing the above in the console, run console.log(ret) to view your IndexedDB data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment