@jacobmarshall/serviceworker-storage
v0.1.0
Published
localStorage like storage in ServiceWorker
Downloads
2
Readme
serviceworker-storage
Storage that can be used like a localStorage easy-to-use on ServiceWorker.
install
npm install git://github.com/RyotaSugawara/serviceworker-storage.git
usage
new ServiceWorkerStorage(name, version)
create instance.
- name: your storage name.
- version: version number.
import ServiceWorkerStorage from 'serviceworker-storage';
const storage = new ServiceWorkerStoarge('MyStorage', 1);
getItem(key)
get item by key.
- key: storage unique key.
storage.getItem('key').then(value => {
console.log(value);
});
setItem(key, value)
set item to key.
- key: storage unique key.
- value: value you want to save.
storage.setItem(key, value);
removeItem(key)
remove item by key.
- key: storage unique key.
storage.removeItem(key);
clear()
clear storage.
storage.clear();