Spaces:
Sleeping
Sleeping
Download apps/api/src/services/monitoring/jitter.ts from s-eto-hub/firecrawl-api: direct link, hf CLI and curl.
- Browser
- Download file 390 Bytes
-
https://huggingface.co/spaces/s-eto-hub/firecrawl-api/resolve/main/apps/api/src/services/monitoring/jitter.ts
- Command line
-
hf download hf://spaces/s-eto-hub/firecrawl-api/apps/api/src/services/monitoring/jitter.ts
-
curl -L -o jitter.ts https://huggingface.co/spaces/s-eto-hub/firecrawl-api/resolve/main/apps/api/src/services/monitoring/jitter.ts
390 Bytes
| import { createHash } from "crypto"; | |
| const MAX_JITTER_MS = 5 * 60 * 1000; | |
| export function monitorJitterOffsetMs( | |
| monitorId: string, | |
| intervalMs: number, | |
| ): number { | |
| const jitterMaxMs = Math.min(Math.floor(intervalMs / 2), MAX_JITTER_MS); | |
| if (jitterMaxMs <= 0) return 0; | |
| const hash = createHash("sha256").update(monitorId).digest(); | |
| return hash.readUInt32BE(0) % jitterMaxMs; | |
| } | |