// 对象相关处理
function clearNullProps(obj: any) {
    for (const key in obj) {
        if (obj[key] === null || obj[key] === undefined) {
            delete obj[key]
        }
    }
}

// 计算父节点和子节点的总数
function getNodesSize(nodes: any[], childrenKey = 'children') {
    let size = 0
    for (const node of nodes) {
        size += 1
        if (node[childrenKey]?.length > 0) {
            size += getNodesSize(node.children, childrenKey)
        }
    }
    return size
}

export default {
    clearNullProps,
    getNodesSize,
}
