@juspay/neurolink
Version:
The pipe layer of an AI nervous system: one interface connecting provider neurons to your application, across three inference types — generate, stream and decide. `decide` returns typed, calibrated judgements from a non-generative model (~400ms, ~$0.00002
40 lines (39 loc) • 1.69 kB
TypeScript
/**
* Parses a duration string (e.g., "6m0s", "30s", "1h30m", "500ms") into milliseconds.
*
* @param raw - The raw duration string
* @returns Duration in milliseconds, or undefined if invalid
*/
export declare function parseDurationMs(raw: string): number | undefined;
/**
* Parses a single Retry-After header value into milliseconds.
*
* Checks in strict order:
* 1. Strict numeric seconds (e.g. "5", "120", "1.5") without truncation of dates or durations
* 2. HTTP-date or RFC 3339 / ISO 8601 date (e.g. "2026-10-18T12:00:00Z" or "Sun, 18 Oct 2026 12:00:00 GMT")
* 3. Duration string (e.g. "6m0s", "30s", "1h30m", "500ms")
*
* @param value - The header value string
* @returns Milliseconds to wait, or undefined if not parseable
*/
export declare function parseRetryAfterHeaderValue(value: string | null | undefined): number | undefined;
/**
* Parses X-RateLimit-Reset header value into milliseconds until reset.
*
* Handles:
* - Delta seconds when value < 1e9 (e.g. "30", "60")
* - Epoch seconds when 1e9 <= value <= 1e12
* - Epoch milliseconds when value > 1e12
* - Fallback to date or duration strings
*
* @param value - The X-RateLimit-Reset header value
* @returns Milliseconds until reset, or undefined if not parseable
*/
export declare function parseRateLimitResetValue(value: string | null | undefined): number | undefined;
/**
* Parse standard and commonly used rate-limit response headers.
*
* @returns The requested delay in milliseconds, or undefined when the
* response does not provide a usable rate-limit delay.
*/
export declare function parseRetryAfterMs(headers: Pick<Headers, "get"> | Readonly<Record<string, string>>): number | undefined;