@alzalabany/storage
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

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

  • [X] Promise based
  • [x] throw error if key is missing
  • [x] throw error if key expired
  • [x] Works with Browser SessionStorage, LocaStorage
  • [x] Works with node Storage
  • [x] 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)

Package Sidebar

Install

npm i @alzalabany/storage

Weekly Downloads

0

Version

0.1.1

License

MIT

Unpacked Size

14.6 kB

Total Files

6

Last publish

Collaborators

  • zalabany