Documentation
    Preparing search index...

    Interface FetchResponse

    The subset of a fetch response this package reads.

    Structural on purpose, exactly as @fourjs/input declares its pointer events: the DOM/undici Response satisfies it, and so does { ok: true, status: 200, … } in a test. Naming Response would drag a DOM lib into a package that must build under plain lib.es2022.

    interface FetchResponse {
        body?: ReadableBodyLike | null;
        contentLength?: number;
        headers?: ResponseHeadersLike;
        ok: boolean;
        status: number;
        arrayBuffer(): Promise<ArrayBuffer>;
        json(): Promise<unknown>;
        text(): Promise<string>;
    }
    Index
    body?: ReadableBodyLike | null

    A chunked body, when the transport can yield one (§76 streaming).

    Structural: the DOM's ReadableStream satisfies ReadableBodyLike (getReader() → { read(), releaseLock? }). Absent on a one-shot fake, in which case AssetManager.stream yields the whole FetchResponse.arrayBuffer once.

    contentLength?: number

    Declared body size in bytes when the transport has no header map.

    Optional: a real Response already exposes this via headers.get("content-length"), which the manager reads first. A test fake — or a non-HTTP transport — may set the field instead. Either source is the same number: an early bound, never the whole §96 check.

    The response headers, if the transport has any (§96).

    Optional because a non-HTTP transport — or a unit test's fake — has none, and because it was added after the interface shipped; the DOM's Headers satisfies it structurally, so a real Response still needs no adapter. The manager reads exactly one header from it, content-length, to refuse an over-budget body before downloading it.

    ok: boolean

    Whether the status is in the 2xx range.

    status: number

    The HTTP status code; 0 is acceptable for non-HTTP transports.

    • The body as bytes.

      Returns Promise<ArrayBuffer>

    • The body parsed as JSON.

      Returns Promise<unknown>

    • The body decoded as UTF-8 text.

      Returns Promise<string>