UNPKG

@nodeject/ui-components

Version:

UI library for non-trivial components

23 lines (22 loc) 617 B
export interface Item { id?: string | number; parentId?: string | number | null; [key: string]: any; } export interface TreeItem { id?: string | number; parentId?: string | number | null; [key: string]: Item | TreeItem[] | any; } export interface Config { id: string; parentId: string; dataField: string | null; childrenField: string; throwChildrenFieldIfEmpty: boolean; throwIfOrphans: boolean; } /** * Unflattens an array to a tree with runtime O(n) */ export declare function arrayToTree(items: Item[], config?: Partial<Config>): TreeItem[];