MCPcopy Create free account
hub / github.com/Effect-TS/effect / parseResetHeader

Function parseResetHeader

packages/effect/src/unstable/http/HttpClient.ts:1365–1381  ·  view source on GitHub ↗
(
  clock: Clock,
  value: string | undefined
)

Source from the content-addressed store, hash-verified

1363}
1364
1365const parseResetHeader = (
1366 clock: Clock,
1367 value: string | undefined
1368): Duration.Duration | undefined => {
1369 const numeric = parseNumberHeader(value)
1370 if (numeric === undefined || numeric <= 0) {
1371 return undefined
1372 }
1373 const nowMillis = clock.currentTimeMillisUnsafe()
1374 if (numeric > 1_000_000_000_000) {
1375 return Duration.millis(Math.max(numeric - nowMillis, 1))
1376 }
1377 if (numeric > 1_000_000_000) {
1378 return Duration.millis(Math.max((numeric * 1_000) - nowMillis, 1))
1379 }
1380 return Duration.max(Duration.seconds(numeric), Duration.millis(1))
1381}
1382
1383const parseNumberHeader = (value: string | undefined): number | undefined => {
1384 if (value === undefined) {

Callers 1

parseRateLimitWindowFunction · 0.85

Calls 2

parseNumberHeaderFunction · 0.85

Tested by

no test coverage detected