( clock: Clock, value: string | undefined )
| 1333 | } |
| 1334 | |
| 1335 | const 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 | |
| 1357 | const parseResetAfter = (value: string | undefined): Duration.Duration | undefined => { |
| 1358 | const numeric = parseNumberHeader(value) |
no test coverage detected