1.4.2 • Published 3 months ago

@uppercod/exp-route v1.4.2

Weekly downloads
-
License
ISC
Repository
github
Last release
3 months ago

@uppercod/exp-route

Path expression syntax for capturing parameters.

Install

npm install @uppercod/exp-route

Syntax

fixed route

/folder1/folrder2

parameter path

/folder1/{folder}

optional parameter path

/folder1/[folder]

spread parameter path

/folder1/[...folder]
/folder1/{...folder}

Api

declare module "@uppercod/exp-route" {
    export interface Params {
        [param: string]: string;
    }
    export type Match<T = Params> = (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<T = Params>(
        search: string,
        master?: Params
    ): T;
    /**
     * Create a callback to compare the route expression with the given route
     */
    export function createMatch<T = Params>(path: string): Match<T>;
}
1.4.2

3 months ago

1.4.1

3 months ago

1.4.0

3 months ago

1.3.0

3 years ago

1.2.6

3 years ago

1.2.5

3 years ago

1.2.4

3 years ago

1.2.3

3 years ago

1.2.2

3 years ago

1.2.1

3 years ago

1.2.0

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.0

4 years ago