goodrouter
Version:
a good router
65 lines (64 loc) • 1.89 kB
TypeScript
import { RouteNodeJson } from "./json.js";
/**
* @description
* This interface represents a node in the tree structure that holds all the node
* for the routes
*/
export declare class RouteNode<K extends string | number> {
/**
* @description
* suffix that comes after the parameter value (if any!) of the path
*/
anchor: string;
/**
* @description
* does this node have a parameter value
*/
hasParameter: boolean;
/**
* @description
* key that identifies the route, if this is a leaf node for the route
*/
routeKey: K | null;
/**
* @description
* children that represent the rest of the path that needs to be matched
*/
private readonly children;
constructor(
/**
* @description
* suffix that comes after the parameter value (if any!) of the path
*/
anchor?: string,
/**
* @description
* does this node have a parameter value
*/
hasParameter?: boolean,
/**
* @description
* key that identifies the route, if this is a leaf node for the route
*/
routeKey?: K | null,
/**
* @description
* children that represent the rest of the path that needs to be matched
*/
children?: RouteNode<K>[]);
private addChild;
private removeChild;
countChildren(): number;
insert(routeKey: K, templatePairs: Array<readonly [string, string | null]>): RouteNode<K>;
parse(path: string, maximumParameterValueLength: number): [K | null, string[]];
private merge;
private mergeNew;
private mergeJoin;
private mergeIntermediate;
private mergeAddToChild;
private mergeAddToNew;
private findSimilarChild;
compare(other: RouteNode<K>): 0 | 1 | -1;
toJSON(): RouteNodeJson<K>;
static fromJSON<K extends string | number>(json: RouteNodeJson<K>): RouteNode<K>;
}