A small and simple free dependency to manage localstorage.
npm install dw-localstore
const localStore = require('dw-localstore')
localStore.set("color",{
id : 1
name : "red"
});
let color = localStore.get("color");
console.log(color); // color object
localStore.update("color",{
id : 2
description:"My favorite color"
});
localStore.subscribe("color",(data)=>{
console.log("color key has changed",data);
})
if(localStore.has("color") && localStore.hasProperty("color","id")){
console.log("valid color");
}
localStore.remove("color")
window.schemas = {
"dog" : {id:1,name:"Poppy"}
};
let dog = localStore.get("dog");
console.log(dog);
All data is saved base64 encoded
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.