templates-mo
Version:
Templates is a scaffolding framework that makes code generation simple, dynamic, and reusable. Generate files, parts of your app, or whole project structures—without the repetitive copy-pasting
30 lines (29 loc) • 779 B
TypeScript
interface AnyTree extends Tree {
}
export interface TreeCallBack<TType, TReturn = void> {
(tree: TType): TReturn;
}
/**
* Tree
*/
export declare class Tree<TData = any, TType extends Tree = AnyTree> {
value: TData | null;
children: TType[];
depth: number;
['constructor']: new (value: TData) => this;
constructor(value?: TData);
addChild(value: TType): TType;
isRoot(): boolean;
hasChildren(): boolean;
/**
* Breath Methods
*/
breathFirstEach(cb: TreeCallBack<TType, boolean | void>): void;
breathFirstSelect(cb: TreeCallBack<TType, boolean>): TType[];
/**
* Depth Methods
*/
depthFirstEach(cb: TreeCallBack<TType>): void;
depthFirstSelect(cb: TreeCallBack<TType, boolean>): TType[];
}
export {};