export = RouteMap; /** * @exports RouteMap * @class RouteMap * @extends Map * @author 7kasper * @classdesc * Special map implementation for routes. * Routes are stored internally as register RegExp -> route, * All default map functions have been suplemented * to support regex and path-parameter functions. */ declare class RouteMap extends Map { /** * Transforms or bakes a regex from the specified string. * This regex supports the following patterns in the string: * * - `:variable` — matches a single url segment and captures it. * - `:variable*` — named greedy capture; matches everything under the * preceding `/`, including empty. Captured group ``. Example: * `/api/:rest*` matches `/api/`, `/api/a`, `/api/a/b`; the `rest` group * captures the tail (`""`, `"a"`, `"a/b"`). Single-star form: rest must * live after a slash. * - `:variable**` — named greedy capture; matches BOTH the index path * itself AND everything under `/`. Captured group includes the leading * slash when present. Example: `/api:rest**` matches `/api`, `/api/`, * `/api/a`; `rest` captures `""`, `"/"`, `"/a"`. * - `//` (middle star) — matches exactly one url segment. * - `/` at end — matches everything under `x/` (but NOT `x` itself). * Example: `/api/` matches `/api/a`, `/api/a/b`, `/api/`; not `/api`. * - `/` at end — same as `/` (everything under `x/`, not `x`). * Example: `/api/` matches `/api/a`, `/api/a/b`, `/api/`; not `/api`. * - `` at end (no leading slash, e.g. `/api`) — matches BOTH * the index `x` AND everything under `x/`. Example: `/api` matches * `/api`, `/api/`, `/api/a`, `/api/a/b`. * (The literal characters are an asterisk — substitute mentally; writing * the real glyphs here would close this JSDoc block comment early.) * @param {string} str - the string to create regex from. * @returns a regex based on the url string. */ static bakeRegex(str: string): RegExp; constructor(); constructor(entries?: readonly (readonly [any, any])[]); constructor(); constructor(iterable?: Iterable); /** * Registers / sets a certain route to a certain map. * If instead of a regex a string is provided it will be * baked following using the `bakeRegex()` * @param {string} path * @param {*} route * @returns this map. */ set(path: string, route: any): this; /** * Checks if there are one or more routes belonging * to the specified path. * @param {string} path * @returns true, if the map contains a match. */ has(path: string): boolean; /** * Gets all routes belonging to a certain path and * returns the path parameters. * * This function is a bit different from a 'normal' get * as it compiles not only an array of matched routes, but * also an object containing all path-parameters specified by * those routes in merged formfactor. * * If the provided path is given in RegExp form the function * will act as expected from a normal map. * * @param {string} path * @returns an object contiaining all matched 'routes' * and a merged array of all 'pathParams' */ get(path: string): any; /** * Deletes all records matching a certain path from this routing map. * Though not recommended the routingmap can be * altered 'on the fly'. This method will delete * all methods belonging to a regex matching with the specified path. * If a regex is specified as path only the exact match will be deleted. * * @param {string} path * @returns true if a match has been deleted, false if not. */ delete(path: string): boolean; }