flushToStorage function infrastructure ✓ 100.0%

Last updated: 2026-03-01T23:25:47.125Z

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)

graph LR flushToStorage["flushToStorage"] hasSessionStorage["hasSessionStorage"] flushToStorage -->|calls| hasSessionStorage style flushToStorage fill:#dbeafe,stroke:#2563eb,stroke-width:2px click flushToStorage "6a2d1616005381ca.html" click hasSessionStorage "a7e74519d0293203.html"
TargetType
hasSessionStorage calls
STORAGE_KEY dynamic_call

No incoming dependencies.