1.1.0 • Published 2 years ago
losge v1.1.0
Use normal JavaScript objects, save them in localstorage, load them or load a default object.
losge(initial, key)
Usage
let data = losge({ value: 99 }) // just wrap with losge
data.value += 1 // make changes
data.save() // saveThe losge call will load the last saved value. If there's no saved value, the argument is used as the initial value.
Resetting
data = data.freshedThe freshed getter will remove the saved values and return a losge with
initial value. Ready to be changed and saved or even freshed again.
Update multiple properties at once and save
data.update({ value: 88 })Dealing with multiple storage keys
Losge is nothing more than a pretty wrapper that adds save and freshed
utility methods. This means you can integrate your existing localstorages to
losge. The second argument is the key to save localstorage. By default it uses
"losge" but you can change them to use multiple top level losges or adapt your
current localstorage objects to losge.