idb-localstorage
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

LocalStorage compliant Indexed DB storage

Usage

import { Store } from 'idb-localstorage';

const store = new Store('db-name', 'store-name');  
store.setItem('hello', 'world');
store.setItem('foo', 'bar');

NOTE: All methods return Promise

API

get:

// logs: "world"
store.getItem('hello').then(val => console.log(val));

If there is no 'hello' key, then val will be undefined.

keys:

import { keys } from 'idb-keyval';

// logs: ["hello", "foo"]
store.keys().then(keys => console.log(keys));

del:

import { del } from 'idb-keyval';

store.removeItem('hello');

clear:

import { clear } from 'idb-keyval';

store.clear();

Package Sidebar

Install

npm i idb-localstorage

Weekly Downloads

6

Version

0.2.0

License

Apache-2.0

Unpacked Size

20 kB

Total Files

16

Last publish

Collaborators

  • wtrocki