A small Javascript Library aimed at making it easier to read and write to localstorage
var _p = new Persistence();
var _p = new Persistence();
var allData = _p.getPersistenceStates(); //returns JSON Object of all data
var _p = new Persistence();
var specificData = _p.getPersistenceState('key'); //returns value of that key in the JSON object of all localstorage for this intance
var _p = new Persistence();
var newData = {foo: "bar"};
var updatedData = _p.setPersistenceState(newData); //updates localstorage and returns JSON Object of all updated data
var _p = new Persistence();
_p.clearPersistenceStates(); //resets localstorage and deletes all data for that Persistence instance
var _p = new Persistence();
_p.setExpirationDays(5); //sets expiration of data to 5 days
var _p = new Persistence();
_p.getExpirationDays(); //returns expiration of data in this instance
A Persistence object uses a key in local storage to set the data, by default its appData
. To change:
var _p = new Persistence();
_p.setAppDataKey('newAppKey'); //sets the key in localStorage for this persistence object to "newAppKey"
var _p = new Persistence();
_p.getAppDataKey(); //sets the key in localStorage for this persistence object to "newAppKey"