@push.rocks/smartrequest
Version:
A module for modern HTTP/HTTPS requests with support for form data, file uploads, JSON, binary data, streams, and more.
33 lines (32 loc) • 920 B
TypeScript
import * as types from './types.js';
/**
* Abstract Core Response class that provides a fetch-like API
*/
export declare abstract class CoreResponse<T = any> implements types.ICoreResponse<T> {
protected consumed: boolean;
abstract readonly ok: boolean;
abstract readonly status: number;
abstract readonly statusText: string;
abstract readonly headers: types.Headers;
abstract readonly url: string;
/**
* Ensures the body can only be consumed once
*/
protected ensureNotConsumed(): void;
/**
* Parse response as JSON
*/
abstract json(): Promise<T>;
/**
* Get response as text
*/
abstract text(): Promise<string>;
/**
* Get response as ArrayBuffer
*/
abstract arrayBuffer(): Promise<ArrayBuffer>;
/**
* Get response as a web-style ReadableStream
*/
abstract stream(): ReadableStream<Uint8Array> | null;
}