LocalStorage watcher
Watch changes in browser localStorage
Installation
Simply run npm install localstorage-watcher --save
or clone the repository.
Usage
The whole system works on storageWatcher
global variable.
Methods and Properties
settings
private property, an object that holds default settings. Default settings are:- duration defaults to 1500ms or 1.5 seconds
- logType defaults to "info" which logger will use to run
console.info
. Other options areerror
,log
,table
,warn
- verbose defaults to
true
that will allow logger to log changes, difference of storageWatcher.lastStorage and window.localStorage. To turn logger off, change this tofalse
configure
public method, this method configures settings.start
public method, starts the watcherstop
public method, stops the watcherlastStorage
public property, holds last storage object before recent change
Using methods
var watcher = storageWatcher; // Configure watcher watcher // Start watcher watcherstart; // add to storage to see the watcher's behavior localStorage; // on next watch cycle, the watcher will log the change and the difference of watcher.lastStorage and window.localStorage // Stop watcher watcher // Get the last saved storage watcherlastStorage
Example
In the example folder, open index.html in browser and you will see a logger system similar to your browser console and bunch of useful buttons.