@riqra/hierarchy-parser
Version:
<p align="center"> <img src="https://res.cloudinary.com/riqra/image/upload/v1513825837/github/hierarchy-parser.svg" /> </p>
14 lines (13 loc) • 460 B
TypeScript
export interface HierarchyParserOptions {
identifier?: string;
parentKey?: string;
initialParentId?: string | number | null;
}
export declare type HierarchyItem<T> = {
[K in keyof T]: T[K];
} & {
children?: HierarchyItem<T>[];
};
export default function hierarchyParser<InputItem extends {
[k: string]: unknown;
}>(dataSource: Readonly<InputItem[]>, options?: Readonly<HierarchyParserOptions>): HierarchyItem<InputItem>[];