exp-route, designed to compare routes on the client based on simple expressions
npm install @uppercod/exp-routebash
npm install @uppercod/exp-route
`
Syntax
$3
`
/folder1/folrder2
`
$3
`
/folder1/{folder}
`
$3
`
/folder1/[folder]
`
$3
`
/folder1/[...folder]
/folder1/{...folder}
`
Api
`ts
declare module "@uppercod/exp-route" {
export interface Params {
[param: string]: string;
}
export type Match = (path: string) => T | undefined;
/**
* Separate the pathname from the search
* @example
* "/before?after" = ["/before","?after"]
*/
export function getParts(path: string): [string, string];
/**
* Capture the search parameters of a string that begins with the character ?
* @example
* "?id=10"
* @param search
* @param master - Object to be used to store the captured indices
*/
export function searchParams(
search: string,
master?: Params
): T;
/**
* Create a callback to compare the route expression with the given route
*/
export function createMatch(path: string): Match;
}
``