window-async-local-storage
v1.1.0
Published
Async localStorage for browser
Downloads
162
Maintainers
Readme
window-async-local-storage
Async localStorage for browser that provides the same interface as window.localStorage.
:star2: Features
- Fully compatible with window.localStorage
- 0 dependency
- Supports all API of AsyncStorage
- Can use IndexedDB as backend (Work in Progress)
:green_book: Quick Start
import AsyncLocalStorage from 'window-async-local-storage';
// import { getItem, setItem, removeItem, clear } from "window-async-local-storage";
await asyncLocalStorage.getItem('my-item');
await asyncLocalStorage.setItem('my-item', 12345);
await asyncLocalStorage.removeItem('my-item');
await asyncLocalStorage.clear();
For more API please refer to AsyncStorage.
Please note that callbacks are not implemented as it is marked as legacy for AsyncStorage as well.
Can be used with window.localStorage
at the same time:
import { getItem } from "window-async-local-storage;
localStorage.setItem("my-item", "12345");
await getItem("my-item"); // 12345