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

Function parseResetHeader

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

Source from the content-addressed store, hash-verified

1930}
1931
1932const parseResetHeader = (
1933 clock: Clock,
1934 value: string | undefined
1935): Duration.Duration | undefined => {
1936 const numeric = parseNumberHeader(value)
1937 if (numeric === undefined || numeric <= 0) {
1938 return undefined
1939 }
1940 const nowMillis = clock.currentTimeMillisUnsafe()
1941 if (numeric > 1_000_000_000_000) {
1942 return Duration.millis(Math.max(numeric - nowMillis, 1))
1943 }
1944 if (numeric > 1_000_000_000) {
1945 return Duration.millis(Math.max((numeric * 1_000) - nowMillis, 1))
1946 }
1947 return Duration.max(Duration.seconds(numeric), Duration.millis(1))
1948}
1949
1950const parseNumberHeader = (value: string | undefined): number | undefined => {
1951 if (value === undefined) {

Callers 1

parseRateLimitWindowFunction · 0.85

Calls 2

parseNumberHeaderFunction · 0.85

Tested by

no test coverage detected