putainde-localstorage
A simple localStorage abstraction
localstorage
allow you to easily store & use JSON data.
Installation
You can install putainde-localstorage from npm
$ npm install putainde-localstorage
putainde-localstorage
can obviously be downloaded directly.
Usage
var localstorage = // create instancevar storage = localstorage// same asvar LocalStorage = var storage = namespace: "myComponent" // set & getstoragestorage // => {bar: "baz"} // removestorage // remove allstorageclear
localstorage.create(options)
> storage
Create a new instance (== new localstorage(options)
)
options
options.namespace
Use a namespace for all your data stored (default storage.
)
storage.set(key, value)
Setter. Accept string, numeric, object...
storage.set({key: value})
Alternative way to set (multiple) value(s).
storage.get(key)
Getter.
storage.get()
Returns all values.
storage.remove(key)
Remove a value.
storage.clear()
Remove all values.
Contributing
Work on a branch, install dev-dependencies, respect coding style & run tests before submitting a bug fix or a feature.
git clone https://github.com/putaindecode/localstorage.gitgit checkout -b patch-1npm installnpm test