hd-utils
Version:
A handy utils for modern JS developers
30 lines (29 loc) • 1.05 kB
TypeScript
/**
*@important --Browser Only --
*@description A utility class for handling and updating URL parameters, paths, and fragments in the browser with/without page refresh."
*@example const browserUrl = new BrowserURLUpdater("www.foo.com");
* browserUrl.setQueryParam("bar", "1"); // will set the url to "www.foo.com/?bar=1" and update the url without refresh.
*
*/
export default class BrowserURLUpdater {
private _url;
private _reload;
private _state;
constructor(url?: string, reloadOnEveryChange?: boolean | undefined);
updateURL(): void;
setQueryParam(key: string, value: string | undefined): void;
removeQueryParam(key: string): void;
getQueryParam(key: string): string | null;
getPath(): string;
setPath(path: string): void;
removePath(): void;
setFragment(fragment: string): void;
getFragment(): string;
removeFragment(): void;
set url(value: string);
get url(): string;
get reload(): boolean;
set reload(value: boolean);
get state(): any;
set state(value: any);
}