UNPKG

@devexcelsior/session-ring

Version:

Browser-local snapshot buffer for healing-aware UIs

25 lines (24 loc) 701 B
"use strict"; // © 2025 DevExcelsior – Commercial use prohibited. License required. // Contact: curtnpuckett@gmail.com Object.defineProperty(exports, "__esModule", { value: true }); exports.SessionRing = void 0; class SessionRing { constructor(maxSnapshots = 10) { this.buffer = new Array(maxSnapshots); this.max = maxSnapshots; this.cursor = 0; } write(snapshot) { this.buffer[this.cursor] = snapshot; this.cursor = (this.cursor + 1) % this.max; } read() { return [...this.buffer].filter(Boolean); } clear() { this.buffer = new Array(this.max); this.cursor = 0; } } exports.SessionRing = SessionRing;