import type { HttpResponse, HyperTransport, HyperBody } from "@hyperttp/types"; type TransportResponse = Awaited>; declare const RAW_CACHE: unique symbol; declare const TEXT_CACHE: unique symbol; declare const JSON_CACHE: unique symbol; type CacheHolder = { [RAW_CACHE]?: Uint8Array; [TEXT_CACHE]?: string; [JSON_CACHE]?: unknown; }; /** * @ru Быстрое клонирование тела ответа с поддержкой structuredClone, JSON и ручного копирования. * @en Fast response body clone supporting structuredClone, JSON, and manual copy. * @param body - The body value to clone. * @returns Cloned body. */ export declare const cloneBodyFast: (body: T) => T; /** * @ru Реализация HttpResponse с ленивым потреблением тела, кэшированием raw/text/json и поддержкой пулинга. * @en HttpResponse implementation with lazy body consumption, raw/text/json caching, and pooling support. */ export declare class HyperHttpResponse implements HttpResponse, CacheHolder { status: number; headers: Record; body: T | HyperBody | Uint8Array | null; url: string; data: T | null; [RAW_CACHE]: Uint8Array | undefined; [TEXT_CACHE]: string | undefined; [JSON_CACHE]: unknown | undefined; private _bodyConsumed; private _raw; constructor(rawResponse?: TransportResponse); /** * @ru Инициализирует ответ из транспортного ответа. Сбрасывает все кэши. * @en Initializes the response from a transport response. Resets all caches. * @param rawResponse - The raw transport response. * @returns This instance for chaining. */ init(rawResponse: TransportResponse): this; private _consumeBody; /** * @ru Возвращает тело ответа как ArrayBuffer, потребляя его при необходимости. * @en Returns the response body as ArrayBuffer, consuming it if necessary. * @returns Promise resolving to an ArrayBuffer. */ arrayBuffer(): Promise; text(): Promise; /** * @ru Возвращает тело ответа, разобранное как JSON. Для объектов возвращает их напрямую (без потребления). * @en Returns the response body parsed as JSON. Returns objects directly (no consumption). * @returns Promise resolving to the parsed JSON value. */ json(): Promise; /** * @ru Полный сброс состояния для переиспользования в пуле. Очищает все кэши и приватные поля. * @en Full state reset for pool reuse. Clears all caches and private fields. */ reset(): void; /** * @ru Сбрасывает тело ответа (для стримов — отменяет/cancel). * @en Discards the response body (cancels streams). * @returns Promise that resolves when the body is discarded. */ dump(): Promise; /** * @ru Клонирует ответ с разделением стримов через tee(). * @en Clones the response, splitting streams via tee(). * @returns A new HttpResponse instance. */ clone(): HttpResponse; } export declare const responsePool: HyperHttpResponse[]; /** * @ru Создаёт HttpResponse из транспортного ответа с переиспользованием пула. * @en Creates an HttpResponse from a transport response reusing the pool. * @param rawResponse - The raw transport response. * @returns An HttpResponse instance. */ export declare const mapResponseFast: (rawResponse: TransportResponse) => HttpResponse; /** * @ru Возвращает HttpResponse в пул переиспользования. * @en Returns an HttpResponse to the reuse pool. * @param res - The response to recycle. */ export declare const recycleResponse: (res: HttpResponse) => void; /** * @ru Создаёт StreamResponse без потребления тела. * @en Creates a StreamResponse without consuming the body. * @param rawResponse - The raw transport response. * @returns A StreamResponse-like object. */ export declare const mapStreamFast: (rawResponse: TransportResponse) => { status: number; headers: Record; body: import("@hyperttp/types").TransportResponsePayload; url: string; }; /** * @ru Быстрое слияние заголовков с мутацией базового объекта. * @en Fast header merge mutating the base object. * @param base - Base headers object (mutated). * @param override - Optional headers to overlay. * @returns The mutated base headers object. */ export declare const mergeHeadersFast: (base: Record, override?: Record) => Record; export {}; //# sourceMappingURL=response.d.ts.map