shelving
Version:
Toolkit for using data in JavaScript.
51 lines (50 loc) • 2.25 kB
TypeScript
import { type PossibleURIParams, type URIParams, type URIScheme } from "../util/uri.js";
import { type PossibleURL, type URL, type URLString } 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(): URLString;
set href(href: URLString);
get origin(): URLString;
get protocol(): URIScheme;
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(): URIParams;
/** 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;
/** Set all params in this URL (all current params are cleared). */
setParams(params: PossibleURIParams): void;
/** Set a single named param in this URL. */
setParam(key: string, value: unknown): void;
/** Update several params in this URL (merged with current params). */
updateParams(params: PossibleURIParams): 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;
/** Clear all params from this URL. */
clearParams(): 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: PossibleURIParams): 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;
equal(a: URL, b: URL): boolean;
toString(): string;
}