SnapshotStore <T>
Index
Constructors
Methods
Constructors
constructor
Returns SnapshotStore<T>
Methods
clear
Discards every retained snapshot. The built-in signals do this when they start, so that a session neither samples nor diffs against measurements from before the preceding downtime — pruning is relative to the newest snapshot rather than the wall clock, so stale entries would otherwise survive indefinitely. Clearing on start rather than on stop leaves a finished session readable.
Returns void
getAll
Direct, unwindowed access to the underlying array — used by signals whose handler needs the previous snapshot to compute a delta (e.g. the event loop and storage backend signals read the last entry to measure change since it).
Returns T[]
getSample
Return all snapshots, or only those within the given time window.
Parameters
optionalsampleDurationMillis: number
Returns T[]
push
Add a snapshot and prune entries older than the history window.
Parameters
snapshot: T
now: Date = snapshot.createdAt
Returns void
useSampleWindow
Sizes retention to the window the signal will be sampled over, as handed to it in
start(). Until this is called nothing is pruned at all, so a signal that ignores its start context grows unboundedly.Parameters
maxSampleWindowMillis: number
Returns void
A time-pruning, time-windowed store for
LoadSnapshotvalues. All four built-in signals compose with one of these, and so can yours — it is the only part of their machinery worth reusing.