a2bei4-utils 1.0.5 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1794,23 +1794,23 @@ function flatCompleteTree2NestedTree(nodes, parentId = 0, { idKey = "id", parent
1794
1794
  * @param {T[]} arr - 嵌套树森林
1795
1795
  * @param {string} [idKey='id'] - 主键字段
1796
1796
  * @param {string} [childrenKey='children'] - 子节点字段
1797
- * @returns {any} 找到的节点;未找到返回 `undefined`
1797
+ * @returns {T | undefined} 找到的节点;未找到返回 `undefined`
1798
1798
  */
1799
- const findTreeNodeById = function findTreeNodeByIdFn(id, arr, idKey = "id", childrenKey = "children") {
1799
+ function findTreeNodeById(id, arr, idKey = "id", childrenKey = "children") {
1800
1800
  if (Array.isArray(arr) && arr.length > 0) {
1801
1801
  for (let i = 0; i < arr.length; i++) {
1802
1802
  const item = arr[i];
1803
1803
  if (item[idKey]?.toString() === id?.toString()) {
1804
1804
  return item;
1805
1805
  } else if (Array.isArray(item[childrenKey]) && item[childrenKey].length > 0) {
1806
- const result = findTreeNodeByIdFn(id, item[childrenKey], idKey, childrenKey);
1806
+ const result = findTreeNodeById(id, item[childrenKey], idKey, childrenKey);
1807
1807
  if (result) {
1808
1808
  return result;
1809
1809
  }
1810
1810
  }
1811
1811
  }
1812
1812
  }
1813
- };
1813
+ }
1814
1814
 
1815
1815
  /**
1816
1816
  * 在嵌套树中按 `id` 递归查找节点,并返回其指定属性值。