( clock: Clock, value: string | undefined )
| 1363 | } |
| 1364 | |
| 1365 | const 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 | |
| 1383 | const parseNumberHeader = (value: string | undefined): number | undefined => { |
| 1384 | if (value === undefined) { |
no test coverage detected