(res, bodyText)
| 160 | // ms-precision retry_after_ms (buildRateLimitBody), fall back to the RFC |
| 161 | // Retry-After header (seconds). Returns 0 when neither is present. |
| 162 | function parseRetryAfterMs(res, bodyText) { |
| 163 | try { |
| 164 | const body = bodyText ? JSON.parse(bodyText) : null; |
| 165 | const ms = Number(body && body.retry_after_ms); |
| 166 | if (Number.isFinite(ms) && ms > 0) return Math.ceil(ms); |
| 167 | } catch { /* body is not JSON; fall through to the header */ } |
| 168 | const secs = Number(res && res.headers && res.headers.get && res.headers.get('retry-after')); |
| 169 | if (Number.isFinite(secs) && secs > 0) return secs * 1000; |
| 170 | return 0; |
| 171 | } |
| 172 | |
| 173 | class EvoMapProxy { |
| 174 | constructor(opts = {}) { |
no test coverage detected