UNPKG

unist-util-walker

Version:

Walk unist trees with enter and leave functions

13 lines (12 loc) 435 B
import type { Node, Parent } from 'unist'; export interface WalkerContext { skip(): void; break(): void; remove(): void; replace<N extends Node>(node: N): void; } export declare type VisitorFunction = (this: WalkerContext, node: Node, parent?: Parent, index?: number) => void; export declare function walk<N extends Node>(node: N, { enter, leave }: { enter?: VisitorFunction; leave?: VisitorFunction; }): Node;