@nerdalytics/beacon-rewind
v1.0.0
Published
Persist Beacon state. Rewind when you need to.
Maintainers
Readme
Beacon Rewind
Persist Beacon state. Rewind when you need to.
Persist @nerdalytics/beacon reactive state to SQLite. State changes are automatically saved and restored on restart, with built-in destructive rewind via rewind().
Installation
npm install beacon-rewind --save-exactRequires Node.js >= 22 and @nerdalytics/beacon as a peer dependency.
Quick Start
import { state } from '@nerdalytics/beacon'
import { BeaconRewind } from 'beacon-rewind'
const db = new BeaconRewind({ databasePath: 'app.sqlite' })
const count = state(0)
// Persist state — restores previous value if it exists
const cleanup = db.persist('count', count)
count.set(1)
count.set(2)
count.set(3)
// Rewind 2 steps: 3 → 2 → 1
db.rewind('count', 2)
console.log(count()) // 1
// Stop persisting and drop the table
cleanup?.()Documentation
Full documentation, API reference, and examples available at: github.com/nerdalytics/beacon-rewind
License
MIT
