Utilisation

Measure an operation without relying on wall-clock changes.

Ce type est utilisé par 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);

Déclaration du type

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>;
  }

Membres 11

NomTypeRequisDescription
oklecture seulebooleanOui—
statuslecture seulenumberOui—
statusTextlecture seulestringOui—
urllecture seulestringOuiThe URL that answered, after redirects.
headerslecture seuleHeadersOui—
bodyUsedlecture seulebooleanOui—
arrayBuffer() => Promise<ArrayBuffer>Oui—
bytes() => Promise<Uint8Array>Oui—
text() => Promise<string>Oui—
json() => Promise<unknown>Oui—
chunks(onChunk: (chunk: Uint8Array) => void) => Promise<void>OuiKuito's streaming read, in place of the Streams API: onChunk gets the body piece by piece as it arrives; resolves when it ends.
arrayBuffer — signatures de méthode

Signatures

ts
(): Promise<ArrayBuffer>

Paramètres

Aucun paramètre.

Retourne

Promise<ArrayBuffer>

bytes — signatures de méthode

Signatures

ts
(): Promise<Uint8Array>

Paramètres

Aucun paramètre.

Retourne

Promise<Uint8Array<ArrayBufferLike>>

text — signatures de méthode

Signatures

ts
(): Promise<string>

Paramètres

Aucun paramètre.

Retourne

Promise<string>

json — signatures de méthode

Signatures

ts
(): Promise<unknown>

Paramètres

Aucun paramètre.

Retourne

Promise<unknown>

chunks — signatures de méthode

Signatures

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

Paramètres

NomTypeRequisDescription
onChunk(chunk: Uint8Array) => voidOui—

Retourne

Promise<void>

Généré depuis les déclarations TypeScript publiques : signatures, props et valeurs par défaut viennent de la source vérifiée, les descriptions de sa JSDoc. Aucune valeur par défaut n'est inventée.