Garbage-collectable persistent key-value database for TypeScript
npm i @hazae41/serac
- 100% TypeScript and ESM
- No external dependencies
- Backed by IndexedDB
- Garbage collection
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")