pet-shop
v0.2.1
Published
A simple wrapper of Web Storage API
Downloads
164
Maintainers
Readme
pet-shop
A simple wrapper of Web Storage API.
Installation
npm install pet-shop
Usage
import { PetShop } from 'pet-shop';
// plain-text store
const store = PetShop({
namespace: 'pet-shop',
storage: sessionStorage
});
store.set('abc', 'xyz');
store.get('abc'); // output: 'xyz'
store.size; // output: 1
localStorage.getItem('pet-shop.abc'); // output: 'xyz'
store.remove('abc');
store.has('abc'); // output: false
import { PetShop } from 'pet-shop';
// json store
const store = PetShop({
namespace: 'pet-shop',
storage: localStorage,
json: true
});
store.set('abc', ['xyz']);
store.get('abc'); // output: ['xyz']
store.size; // output: 1
localStorage.getItem('pet-shop.abc'); // output: ['xyz']
store.remove('abc');
store.has('abc'); // output: false