UNPKG

mentoss

Version:

A utility to mock fetch requests and responses.

34 lines (33 loc) 1.26 kB
/** * Parses a URL and returns a URL object. This is used instead * of the URL constructor to provide a standard error message, * because different runtimes use different messages. * @param {string|URL} url The URL to parse. * @returns {URL} The parsed URL. */ export function parseUrl(url: string | URL): URL; /** * Reads the body from a request based on the HTTP headers. * @param {Request} request The request to read the body from. * @returns {Promise<string|any|FormData|null>} The body of the request. */ export function getBody(request: Request): Promise<string | any | FormData | null>; /** * Creates a text representation of a request in the same format as it would * appear in a network panel. * @param {Request} request The request to stringify. * @param {string|any|FormData|null} body The body of the request * @returns {string} The stringified request. */ export function stringifyRequest(request: Request, body: string | any | FormData | null): string; /** * Represents an error that occurs when a URL is invalid. * @extends {Error} */ export class URLParseError extends Error { /** * Creates a new URLParseError instance. * @param {string} url The URL that caused the error. */ constructor(url: string); }