/** * Visit tree by pre or post DFS * @author imcuttle */ declare namespace visitTree { export interface IOptions { path?: string state?: S } export type IVisit = (node: T, ctx: Context) => void } declare function visitTree( node: T, preVisit: visitTree.IVisit, postVisit?: visitTree.IVisit, options?: visitTree.IOptions ): void declare function visitTree( node: T, preVisit: visitTree.IVisit, options?: visitTree.IOptions ): Promise export default visitTree export function sync(node: T, preVisit: visitTree.IVisit, options?: visitTree.IOptions): void export function sync( node: T, preVisit: visitTree.IVisit, postVisit?: visitTree.IVisit, options?: visitTree.IOptions ): void export function walkParentCtx(ctx: Context, walk: (ctx: Context) => void): void export function getParents(ctx: Context): T[] export function getPaths(ctx: Context): number[] export class Context { constructor(props?: any, opts?: any) public opts: any index: number depth: number parent: T | null parentCtx: Context | null parents: T[] readonly children: T[] paths: number[] state: any globalState: S node: T readonly status: 'skip' | 'break' | null skip: () => void break: () => void continue: () => void insertByIndex: (index: number, nodes: T[]) => boolean insertBefore: (...nodes: T[]) => boolean insert: (...nodes: T[]) => boolean remove: () => boolean replace: (node: T) => boolean }