db, store, persist and fs: IndexedDB, localStorage and private files.
db
Keys to values in IndexedDB. A value is anything JSON can hold; every call waits and can fail.
get, set, del, keys, allSet a key, read it back, and see everything the database holds. It is still here after a reload.
key
value
0 keys
db.keys()
Reading…
db.persist, db.persisted, db.roomWhat a site keeps, the browser may clear by itself when the device runs short of room. db.persist asks it not to (true or false; Firefox asks the reader, Chrome and Safari decide by themselves); db.persisted says whether it has agreed, asking nobody; db.room is {used, left} in bytes, a figure to go by. A write that does not fit fails with err.kind == "full", and what was there before is still there.
Not asked yet.
falsedb.persisted()it may be cleared
…useddb.room().used
…leftdb.room().left
store: get, set, removelocalStorage, with values as JSON. It does not wait and does not fail: good for a setting, not for much data.
key
value
Set it, reload the page, then get it.
state … persist
One word after a state keeps it in localStorage under its name: the page opens with what it held.
A value that survives a reloadCount, type, then reload the page to see: both come back as you left them.
0storageVisits
storageNote
Reload to see. The same two values are in localStorage as JSON, under the states' names.
fs
The site's private files: a folder only this origin can read, with real paths. Data is text or bytes.
A small file managerEverything here is in the folder storage-demo/ of the private files. Open a file, change it, save it, delete it.
storage-demo/
Reading…
fs.list(""): the top of the private files
…
Open a file from the list, or make a new one.
Files in and out
fs.pick asks the reader for a file; fs.save hands one over; drop takes what is let go over an element.
fs.pick and fs.saveA picked file arrives as {name, data}: its bytes are the page's to read, keep or hand back.
No file picked yet.
fs.save(data, name): text or bytes, downloaded
A drop targetdrop= runs its handler once for each file let go over the element, with {name, data}.
Drop files hereFrom the desktop or a file window. Nothing leaves the page.