* Parse an x-ratelimit-reset Unix timestamp (seconds) into an ISO 8601 string. * Returns null when the header is absent or unparseable. * * @param {string | undefined} resetHeader * @returns {string | null}
(resetHeader)
| 69 | * @returns {string | null} |
| 70 | */ |
| 71 | function parseResetTimestamp(resetHeader) { |
| 72 | if (!resetHeader) return null; |
| 73 | const seconds = parseInt(resetHeader, 10); |
| 74 | if (isNaN(seconds)) return null; |
| 75 | return new Date(seconds * 1000).toISOString(); |
| 76 | } |
| 77 | |
| 78 | // --------------------------------------------------------------------------- |
| 79 | // Public API |
no outgoing calls
no test coverage detected