/** * Tree walker for TONL documents * * Provides callback-based tree traversal with filtering and early termination */ /** * Walk callback function * * @param path - Current path * @param value - Current value * @param depth - Current depth in the tree * @returns false to stop traversal, true or void to continue */ export type WalkCallback = (path: string, value: any, depth: number) => void | boolean; /** * Walk options */ export interface WalkOptions { /** * Maximum depth to traverse * @default 100 */ maxDepth?: number; /** * Filter function to determine which values to visit * @default undefined (visit all) */ filter?: (value: any) => boolean; /** * Traversal strategy * @default 'depth-first' */ strategy?: 'depth-first' | 'breadth-first'; /** * Visit order for depth-first traversal * @default 'pre-order' */ order?: 'pre-order' | 'post-order'; /** * Whether to include the root node in traversal * @default false */ includeRoot?: boolean; } /** * Walk a tree structure with a callback * * @param value - The root value to walk * @param callback - Function called for each node * @param options - Walk options * * @example * ```typescript * const doc = { user: { name: 'Alice', age: 30 } }; * walk(doc, (path, value, depth) => { * console.log(`[${depth}] ${path}: ${JSON.stringify(value)}`); * }); * ``` */ export declare function walk(value: any, callback: WalkCallback, options?: WalkOptions): void; /** * Count total nodes in a tree * * @param value - The tree to count * @param maxDepth - Maximum depth * @returns Total number of nodes */ export declare function countNodes(value: any, maxDepth?: number): number; /** * Find a value by predicate * * @param value - The tree to search * @param predicate - Function to test each value * @returns First matching value or undefined */ export declare function find(value: any, predicate: (value: any, path: string) => boolean): any; /** * Find all values matching a predicate * * @param value - The tree to search * @param predicate - Function to test each value * @returns Array of matching values */ export declare function findAll(value: any, predicate: (value: any, path: string) => boolean): any[]; /** * Check if any value matches a predicate * * @param value - The tree to search * @param predicate - Function to test each value * @returns True if any value matches */ export declare function some(value: any, predicate: (value: any, path: string) => boolean): boolean; /** * Check if all values match a predicate * * @param value - The tree to search * @param predicate - Function to test each value * @returns True if all values match */ export declare function every(value: any, predicate: (value: any, path: string) => boolean): boolean; //# sourceMappingURL=walker.d.ts.map