MCPcopy Create free account
hub / github.com/codeaashu/claude-code / rateVital

Function rateVital

web/lib/performance/metrics.ts:35–48  ·  view source on GitHub ↗
(name: string, value: number)

Source from the content-addressed store, hash-verified

33// ─── Core Web Vitals ────────────────────────────────────────────────────────
34
35function rateVital(name: string, value: number): PerformanceMetric["rating"] {
36 const thresholds: Record<string, [number, number]> = {
37 LCP: [2500, 4000],
38 FID: [100, 300],
39 CLS: [0.1, 0.25],
40 INP: [200, 500],
41 TTFB: [800, 1800],
42 FCP: [1800, 3000],
43 };
44 const [good, poor] = thresholds[name] ?? [0, Infinity];
45 if (value <= good) return "good";
46 if (value <= poor) return "needs-improvement";
47 return "poor";
48}
49
50export function observeWebVitals(): void {
51 if (typeof window === "undefined" || !("PerformanceObserver" in window)) return;

Callers 1

observeWebVitalsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected