( clock: Clock, value: string | undefined )
| 1930 | } |
| 1931 | |
| 1932 | const 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 | |
| 1950 | const parseNumberHeader = (value: string | undefined): number | undefined => { |
| 1951 | if (value === undefined) { |
no test coverage detected