flushToStorage function infrastructure ✓ 100.0%
Last updated: 2026-03-01T23:25:47.125Z
Location
Metrics
LOC: 21
Complexity: 6
Params: 0
Coverage: 100.0% (12/12 lines, 5x executed)
Signature
flushToStorage(): : Promise<void>
Source Code
async function flushToStorage(): Promise<void> {
flushTimer = null;
if (pendingEntries.length === 0) return;
const toFlush = pendingEntries;
pendingEntries = [];
if (!hasSessionStorage()) return;
try {
const result = await chrome.storage.session.get(STORAGE_KEY);
let all: LogEntry[] = (result[STORAGE_KEY] as LogEntry[] | undefined) ?? [];
all.push(...toFlush);
if (all.length > maxEntries) {
all = all.slice(-maxEntries);
}
await chrome.storage.session.set({ [STORAGE_KEY]: all });
} catch {
// Storage write failed — entries remain in local memory only
}
}
Dependencies (Outgoing)
| Target | Type |
|---|---|
| hasSessionStorage | calls |
| STORAGE_KEY | dynamic_call |
No incoming dependencies.