A simple class to automate storage.
import storage from '@titodp/storage'
// saving to storage
storage.uh = 'YES' // look at storage!
storage.objectToo = { uh: 'YES', wow: 'π' } // look at storage!
// deleting from storage
delete storage.uh
// fancy example
// start with default values
let mySettings = {
uh: 'YES',
wow: 'π',
}
// load any setting that has been saved previously
// and put it on mySettings
mySettings = storage.on(mySettings, 'optional key prefix')
// first time you run this code should show π (the default)
// if you reload it, it should show π₯³ as we saved a new value on the next example
console.log(mySettings.wow)
// change the value and save it to storage
mySettings.wow = 'π₯³'
// reset with mySettings.reset()
npm install @titodp/storage
It sets a proxy trap, serializes when you set and unserializes when you get.