A simple localStorage abstraction
localstorage
allows you to easily store & use JSON data.
You can install putainde-localstorage from npm
$ npm install putainde-localstorage (--save)
putainde-localstorage
can obviously be downloaded directly.
var localstorage = require("putainde-localstorage")
// create instance
var storage = localstorage.create({namespace: "myComponent"})
// same as
var LocalStorage = require("putainde-localstorage")
var storage = new LocalStorage({namespace: "myComponent"})
// set & get
storage.set("foo", {bar: "baz"})
storage.get("foo") // => {bar: "baz"}
// remove
storage.remove("foo")
// remove all
storage.clear()
Create a new instance (== new localstorage(options)
)
Use a namespace for all your data stored (default storage.
)
Setter. Accept string, numeric, object...
Alternative way to set (multiple) value(s).
Getter.
Returns all values.
Remove a value.
Remove all values.
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.git
git checkout -b patch-1
npm install
npm test