losge

1.1.0 • Public • Published

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()                     // save

The 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.freshed

The 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.

Readme

Keywords

Package Sidebar

Install

npm i losge

Weekly Downloads

1

Version

1.1.0

License

MIT

Unpacked Size

2.73 kB

Total Files

5

Last publish

Collaborators

  • va9iff