@rayriffy/datastore
TypeScript icon, indicating that this package has built-in type declarations

2.0.5 • Public • Published

datastore

Browser-level KV store, utilizing both IndexedDB and local storage.

This library will provide benefits of almost unlimited storage size of IndexedDB, with ease of use when interacting with interface like LocalStorage.

If browser does not have IndexedDB, this library will performs a fallback to LocalStorage by itself

Install

pnpm add @rayriffy/datastore

Usage

// initialize (initialize once, use everywhere)
const instance = createInstance('indexedDb-database-name')

// set (lib will JSON.stringify() for you in localStorage)
await instance.setItem('key1', {
  message: 'amogus',
})

// get (default to null) (lib will JSON.parse() for you in localStorage)
const val = await instance.getItem('key1')

// delete
await instance.removeItem('key1')

// clear
await instance.clear()

Publishing

This repository has been configured to automatically publish NPM packages by Changesets. Run pnpm changeset command to publishing your changes before commit.

Readme

Keywords

none

Package Sidebar

Install

npm i @rayriffy/datastore

Weekly Downloads

9

Version

2.0.5

License

MIT

Unpacked Size

16.8 kB

Total Files

13

Last publish

Collaborators

  • rayriffy