MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / clampTimestamp

Function clampTimestamp

telemetry-worker/src/index.ts:152–160  ·  view source on GitHub ↗
(v: unknown)

Source from the content-addressed store, hash-verified

150}
151
152function clampTimestamp(v: unknown): string | undefined {
153 if (typeof v !== 'string') return undefined;
154 const t = Date.parse(v);
155 if (!Number.isFinite(t)) return undefined;
156 const now = Date.now();
157 // Rollups arrive up to a few days late (offline buffers); reject implausible times.
158 if (t > now + 10 * 60_000 || t < now - 30 * 86_400_000) return undefined;
159 return new Date(t).toISOString();
160}
161
162function sanitizeEvent(raw: unknown): StoredEvent | null {
163 if (typeof raw !== 'object' || raw === null) return null;

Callers 1

sanitizeEventFunction · 0.85

Calls 1

parseMethod · 0.80

Tested by

no test coverage detected