Skip to content

jacobmarshall-pkg/serviceworker-storage

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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();

Packages

No packages published

Languages

  • JavaScript 100.0%