1.1.0 • Published 9 months ago

window-async-local-storage v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

window-async-local-storage

npm license size

Async localStorage for browser that provides the same interface as window.localStorage.

Showcasing

: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