Skip to content
/ serac Public

Garbage-collectable persistent key-value database for TypeScript

Notifications You must be signed in to change notification settings

hazae41/serac

Repository files navigation

Serac

Garbage-collectable persistent key-value database for TypeScript

npm i @hazae41/serac

Node Package 📦

Features

Current features

  • 100% TypeScript and ESM
  • No external dependencies
  • Backed by IndexedDB
  • Garbage collection

Usage

import { Database } from "@hazae41/serac";

const database = await Database.openOrThrow("example", 1, () => { })

await database.setOrThrow("kaaa", "vaaa", Date.now())
await database.setOrThrow("kbbb", "vbbb", Date.now() + 1000)
await database.setOrThrow("kccc", "vccc", Date.now() - 1000)

console.log(await database.getOrThrow("kaaa")) // null
console.log(await database.getOrThrow("kbbb")) // "vbbb"
console.log(await database.getOrThrow("kccc")) // null

for await (const value of database.collectOrThrow())
  console.log("Garbage collected", value)

console.log("Garbage collection done")

About

Garbage-collectable persistent key-value database for TypeScript

Resources

Stars

Watchers

Forks

Packages

No packages published