shelving
Version:
Toolkit for using data in JavaScript.
46 lines (45 loc) • 1.94 kB
TypeScript
import type { Data } from "../util/data.js";
import { type PossibleURL, type PossibleURLParams, type URLParams } from "../util/url.js";
import { Store } from "./Store.js";
/** Store a URL, e.g. `https://top.com/a/b/c` */
export declare class URLStore extends Store<URL> {
readonly base: URL | undefined;
constructor(url: PossibleURL, base?: PossibleURL);
set value(url: PossibleURL);
get value(): URL;
get href(): string;
set href(href: string);
get origin(): string;
get protocol(): string;
get username(): string;
get password(): string;
get hostname(): string;
get host(): string;
get port(): string;
get pathname(): string;
/** Get the URL params as a string. */
get search(): string;
/** Get the URL params as a dictionary. */
get params(): URLParams;
/** Return a single param in this URL, or `undefined` if it could not be found. */
getParam(key: string): string | undefined;
/** Require a single param in this URL, or throw `RequiredError` if it could not be found. */
requireParam(key: string): string | undefined;
/** Update a single param in this URL. */
setParam(key: string, value: unknown): void;
/** Update several params in this URL. */
setParams(params: Data): void;
/** Delete one or more params in this URL. */
deleteParam(key: string, ...keys: string[]): void;
/** Delete one or more params in this URL. */
deleteParams(key: string, ...keys: string[]): void;
/** Return the current URL with an additional param. */
withParam(key: string, value: unknown): URL;
/** Return the current URL with an additional param. */
withParams(params: PossibleURLParams): URL;
/** Return the current URL with an additional param. */
omitParams(...keys: string[]): URL;
/** Return the current URL with an additional param. */
omitParam(key: string): URL;
toString(): string;
}