UNPKG

fytable

Version:

A Vue 2.x table component library with tree table and virtual scrolling support

16 lines (14 loc) 416 B
import IS from './is' export function getNodeDepths(treeArray, depth = 0) { const depths = {}; function traverse(nodes, currentDepth) { nodes.forEach(node => { depths[node.id] = {...node,depth:currentDepth}; if (node.children && node.children.length > 0) { traverse(node.children, currentDepth + 1); } }); } traverse(treeArray, depth); return depths; }