UNPKG

@mojojs/core

Version:

Real-time web framework

65 lines (64 loc) 1.67 kB
import type { PlaceholderType } from '../types.js'; interface MatchOptions { isEndpoint: boolean; } type PlaceholderTypes = Record<string, PlaceholderType>; type ASTNode = [symbol, ...string[]]; /** * Route pattern class. */ export declare class Pattern { /** * Pattern constraints. */ constraints: PlaceholderTypes; /** * Pattern default values. */ defaults: Record<string, any>; /** * Placeholder names. */ placeholders: string[]; /** * Pattern in compiled regular expression form. */ regex: RegExp | undefined; /** * Placeholder types. */ types: PlaceholderTypes; /** * Raw unparsed pattern. */ unparsed: string; _ast: ASTNode[]; constructor(path?: string, options?: { constraints?: PlaceholderTypes; defaults?: Record<string, any>; types?: PlaceholderTypes; }); /** * Match pattern against entire path. */ match(path: string, options: MatchOptions): Record<string, any> | null; /** * Match pattern against path and return the remainder. */ matchPartial(path: string, options: MatchOptions): (Record<string, any> & { remainder: string; }) | null; /** * Parse pattern. */ parse(path?: string): this; /** * Render pattern into a path with parameters. */ render(values: Record<string, string>, options: MatchOptions): string; _compile(withExtension: boolean): RegExp; _compileExtension(ext: PlaceholderType, withDefault: boolean): string; _compileType(type: PlaceholderType): string; _tokenize(): void; } export {};