Package Exports
- @alzalabany/storage
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@alzalabany/storage) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
app-storage, Promise based Local Storage for Web, Node, & React-Native
Very small library that makes working localstorage/sessionstorage on web/node/react-native easier by unifying api.
Features
- Promise based
- throw error if key is missing
- throw error if key expired
- Works with Browser SessionStorage, LocaStorage
- Works with node Storage
- Works with React-Native AsyncStorage
import { webStorage } from '@alzalabany/@alzalabany/storage';
const KEY = 'Hello';
const VAL = 'World';
const EXPIRY = 100; // expiry is set in ms.
webStorage.setItem(KEY,VAL, EXPIRY)
setTimeout(()=>{
// this will run after item has expired
webStorage.getItem(KEY)
.then(console.log) // will not resolve
.catch(console.warn) // Expired error will be caught here
},110)