@benev/slate
Version:
frontend web stuff
15 lines (10 loc) • 353 B
text/typescript
import {Annals} from "./annals.js"
export function trim_to_history_limit<X>(array: X[], limit: number) {
while (array.length > limit)
array.shift()
return array
}
export function record_snapshot(history: Annals<any>, state: any, limit: number) {
history.snapshots.push(structuredClone(state))
trim_to_history_limit(history.snapshots, limit)
}