UNPKG

mobx-keystone-mindreframer

Version:

A MobX powered state management solution based on data trees with first class support for Typescript, snapshots, patches and much more

26 lines (25 loc) 950 B
/** * Mode for the `walkTree` method. */ export declare enum WalkTreeMode { /** * The walk will be done parent (roots) first, then children. */ ParentFirst = "parentFirst", /** * The walk will be done children (leafs) first, then parents. */ ChildrenFirst = "childrenFirst" } /** * Walks a tree, running the predicate function for each node. * If the predicate function returns something other than undefined, * then the walk will be stopped and the function will return the returned value. * * @typeparam T Returned object type, defaults to void. * @param target Subtree root object. * @param predicate Function that will be run for each node of the tree. * @param mode Mode to walk the tree, as defined in `WalkTreeMode`. * @returns */ export declare function walkTree<T = void>(target: object, predicate: (node: object) => T | undefined, mode: WalkTreeMode): T | undefined;