2.0.5 • Published 11 months ago

@rayriffy/datastore v2.0.5

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

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.

2.0.5

11 months ago