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

Function parseRetryAfter

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

Source from the content-addressed store, hash-verified

1333}
1334
1335const parseRetryAfter = (
1336 clock: Clock,
1337 value: string | undefined
1338): Duration.Duration | undefined => {
1339 if (value === undefined) {
1340 return undefined
1341 }
1342 const numeric = parseNumberHeader(value)
1343 if (numeric !== undefined) {
1344 return Duration.max(Duration.seconds(numeric), Duration.millis(1))
1345 }
1346 const parsedDate = Date.parse(value)
1347 if (Number.isNaN(parsedDate)) {
1348 return undefined
1349 }
1350 const millis = parsedDate - clock.currentTimeMillisUnsafe()
1351 if (millis <= 0) {
1352 return Duration.millis(1)
1353 }
1354 return Duration.millis(millis)
1355}
1356
1357const parseResetAfter = (value: string | undefined): Duration.Duration | undefined => {
1358 const numeric = parseNumberHeader(value)

Callers 1

inspectResponseFunction · 0.85

Calls 3

parseNumberHeaderFunction · 0.85
parseMethod · 0.45

Tested by

no test coverage detected