@hazae41/serac
v1.0.5
Published
Garbage-collectable persistent key-value database for TypeScript
Downloads
462
Maintainers
Readme
Serac
Garbage-collectable persistent key-value database for TypeScript
npm i @hazae41/serac
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 key of database.collectOrThrow())
await database.deleteOrThrow(key)
console.log("Garbage collection done")