Usage

Measure an operation without relying on wall-clock changes.

This type is used by global.fetch

tsx
// Measure an operation without relying on wall-clock changes.
const start = performance.now();
const response = await fetch('https://example.com/api/health');
console.log(response.status, performance.now() - start);

Type declaration

ts
interface Response {
    readonly ok: boolean;
    readonly status: number;
    readonly statusText: string;
    /** The URL that answered, after redirects. */
    readonly url: string;
    readonly headers: Headers;
    readonly bodyUsed: boolean;
    arrayBuffer(): Promise<ArrayBuffer>;
    bytes(): Promise<Uint8Array>;
    text(): Promise<string>;
    json(): Promise<unknown>;
    /**
     * Kuito's streaming read, in place of the Streams API: `onChunk` gets
     * the body piece by piece as it arrives; resolves when it ends.
     */
    chunks(onChunk: (chunk: Uint8Array) => void): Promise<void>;
  }

Members 11

NameTypeRequiredDescription
okreadonlybooleanYes—
statusreadonlynumberYes—
statusTextreadonlystringYes—
urlreadonlystringYesThe URL that answered, after redirects.
headersreadonlyHeadersYes—
bodyUsedreadonlybooleanYes—
arrayBuffer() => Promise<ArrayBuffer>Yes—
bytes() => Promise<Uint8Array>Yes—
text() => Promise<string>Yes—
json() => Promise<unknown>Yes—
chunks(onChunk: (chunk: Uint8Array) => void) => Promise<void>YesKuito's streaming read, in place of the Streams API: onChunk gets the body piece by piece as it arrives; resolves when it ends.
arrayBuffer — method signatures

Signatures

ts
(): Promise<ArrayBuffer>

Parameters

No parameters.

Returns

Promise<ArrayBuffer>

bytes — method signatures

Signatures

ts
(): Promise<Uint8Array>

Parameters

No parameters.

Returns

Promise<Uint8Array<ArrayBufferLike>>

text — method signatures

Signatures

ts
(): Promise<string>

Parameters

No parameters.

Returns

Promise<string>

json — method signatures

Signatures

ts
(): Promise<unknown>

Parameters

No parameters.

Returns

Promise<unknown>

chunks — method signatures

Signatures

ts
(onChunk: (chunk: Uint8Array) => void): Promise<void>

Parameters

NameTypeRequiredDescription
onChunk(chunk: Uint8Array) => voidYes—

Returns

Promise<void>

Generated from the public TypeScript declarations: signatures, props and defaults come from the checked source, descriptions from its JSDoc. No defaults are invented.