import { PARENT_KEY } from '../constants' ; import type { RowDataType } from '../@types/common' ; param treeData returns function flattenData ( treeData ) { const flattenItems = [ ] ; function loop ( treeData , parentNode ) { if ( ! Array . isArray ( treeData ) ) { return ; } treeData . forEach ( rowData => { rowData [ PARENT_KEY ] = parentNode ; flattenItems . push ( { ... rowData } ) ; if ( rowData . children ) { loop ( rowData . children , rowData ) ; } } ) ; } loop ( treeData , null ) ; return flattenItems ; } export default flattenData ;