erre-ele
v0.2.2
Published
A Typescript browser URL manager
Readme
Erre Ele
A Typescript browser URL manager
Activity
Why?
Why not.
Install
npm i erre-ele --saveUsage
Import
Import the ErreEle singleton instance:
import rl from 'erre-ele';Interface
Review and use to your implementations how the IErreEle interface looks
export interface IErreEle<S> {
getParamFromURL: (pn: string) => string | null;
getPathnameFromURL: () => string | null;
go: (p: string, t?: string, s?: S) => void;
subscribeOnPopState: (onPopState?: (e: PopStateEvent) => void) => void;
setParam: (key: string, value: string) => void;
getParam: (key: string) => void;
}Generic
<S> State type to push in browser history.
Public API
| Public API | Description | |----------------------|----------------------------------------------| | getParamFromURL | Get param value from URL | | getPathnameFromURL | Get path name from URL | | go | Push in browser history | | subscribeOnPopState | Subscribe handler when pop state in history | | params | URL params state | | setParam | Set new param state | | getParam | Get new param state |
Usage
// Browser URL "https://example.com/?foo=bar"
import rl from 'erre-ele';
const fooValue = rl.getParamFromURL('foo'); // bar