Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yinyanfr/window-async-local-storage
Async localStorage for browser
https://github.com/yinyanfr/window-async-local-storage
Last synced: about 1 month ago
JSON representation
Async localStorage for browser
- Host: GitHub
- URL: https://github.com/yinyanfr/window-async-local-storage
- Owner: yinyanfr
- License: mit
- Created: 2023-01-10T14:05:30.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-08-12T14:02:32.000Z (over 1 year ago)
- Last Synced: 2024-10-10T02:52:43.228Z (about 1 month ago)
- Language: TypeScript
- Homepage: https://yinyanfr.github.io/window-async-local-storage/
- Size: 2.5 MB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# window-async-local-storage
[![npm](https://img.shields.io/npm/v/window-async-local-storage.svg)](https://www.npmjs.com/package/window-async-local-storage)
![license](https://img.shields.io/npm/l/window-async-local-storage.svg)
![size](https://img.shields.io/github/repo-size/yinyanfr/window-async-local-storage)Async localStorage for browser that provides the same interface as window.localStorage.
[Showcasing](https://yinyanfr.github.io/window-async-local-storage/)
## :star2: Features
- Fully compatible with window.localStorage
- 0 dependency
- Supports all API of [AsyncStorage](https://react-native-async-storage.github.io/async-storage/docs/api)
- Can use IndexedDB as backend (Work in Progress)## :green_book: Quick Start
```js
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](https://react-native-async-storage.github.io/async-storage/docs/api).
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:
```js
import { getItem } from "window-async-local-storage;localStorage.setItem("my-item", "12345");
await getItem("my-item"); // 12345
```