import { getFieldValue, isArray } from '@cip/utils/util' export const analyseData = (list = [], treeProps, count = 0, parentPath = []) => { return list.reduce((acc, item, index) => { const path = parentPath.concat(index) acc[count] = path count++ const children = getFieldValue(item, treeProps.children) if (isArray(children)) { const indexed = analyseData(children, treeProps, count, path) acc = Object.assign(acc, indexed) count += Object.keys(indexed).length } return acc }, {}) } export const getPropertyKeyByPath = (path, treeProps) => { const { children } = treeProps return path.join(`.${children}.`) }