UNPKG

@wroud/navigation

Version:

A flexible, pattern-matching navigation system for JavaScript applications with built-in routing, browser integration, and navigation state management

30 lines 1.6 kB
import type { RouteParams, RouteParamValue } from "../IRouteMatcher.js"; import { type QueryParamDef } from "./path-utils.js"; /** * Validates that all required parameters are present in the params object. * Throws descriptive errors for missing or invalid parameters. * Optionally validates parameter types if paramTypes is provided. * Optionally validates query parameters if queryDefs is provided. */ export declare function validateParameters(pattern: string, segments: string[], params: RouteParams, paramTypes?: Record<string, string>, // TODO: make it required and remove extra checks queryDefs?: QueryParamDef[]): void; /** * Builds URL segments from a pattern and parameters */ export declare function buildUrlSegments(segments: string[], params: RouteParams, paramTypes?: Record<string, string>): string[]; /** * Convert a raw string value according to declared parameter type. */ export declare function convertParamValue(value: string, type: string): RouteParamValue; /** * Extracts query parameters from a query string based on pattern definitions. * Populates params with converted values. * Returns false if a required query parameter is missing. */ export declare function matchQueryParams(queryDefs: QueryParamDef[], query: string, params: RouteParams): boolean; /** * Builds a query string from pattern definitions and parameters. * Returns the query string including the leading "?" or empty string if no params are set. */ export declare function buildQueryString(queryDefs: QueryParamDef[], params: RouteParams): string; //# sourceMappingURL=parameter-utils.d.ts.map