← Files Codex Browser RecorderARCHIVED FILE

skills/record-browser/scripts/cdp-event-batch.mjs

594 Bytes · Sep 30, 2026 · 23:13 UTC

↓ Download file

export function normalizeCdpEventBatch(batch, currentCursor) {
  if (
    batch === null ||
    typeof batch !== "object" ||
    !Number.isInteger(batch.cursor) ||
    batch.cursor < 0 ||
    (currentCursor !== undefined && batch.cursor < currentCursor) ||
    !Array.isArray(batch.events) ||
    (batch.hasMore !== undefined && typeof batch.hasMore !== "boolean") ||
    (batch.truncated !== undefined && typeof batch.truncated !== "boolean")
  ) {
    return null;
  }

  const { cursor, events, hasMore, truncated } = batch;
  return Object.freeze({ cursor, events, hasMore, truncated });
}

SHA-256: 0318e0699e6a0813a84dac24d82d64b9f5de3b6ea5353360082dfc58eb11ebb0