@mug3n96/asynclocalstorage
v0.2.9
Published
async way to use local storage
Maintainers
Readme
AsyncLocalStorage
DESCRIPTION:
This is a lightweight promised based async wrapper for localStorage.INSTALLATION:
npm i @mug3n96/asynclocalstorage --saveUSE:
require module
const asyncLocalStorage = require('@mug3n96/asynclocalstorage');set item
// you can pass a none stringified object, the methode will stringify it automatically
// (there is no Promise rejection )asyncLocalStorage.setItem('key', {test: 'test'})
.then(value => console.log(value));get item
// if there is no saved item, promise will rejectasyncLocalStorage.getItem('key')
.then(value => console.log(value))
.catch(e => console.log('CANNOT GET THE ITEM'));remove item
// if there is no item with the key 'key' promise will
// rejectasyncLocalStorage.removeItem('key')
.then(data => console.log(data.value, 'of', data.key, 'has been removed'))
.catch(e => console.log(e));clear
// will clear all items of your local storageasyncLocalStorage.clear()
.then(() => {
console.log('do maybe smth after you cleared all items');
});