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.
@@ -1792,23 +1792,23 @@ function flatCompleteTree2NestedTree(nodes, parentId = 0, { idKey = "id", parent
1792
1792
  * @param {T[]} arr - 嵌套树森林
1793
1793
  * @param {string} [idKey='id'] - 主键字段
1794
1794
  * @param {string} [childrenKey='children'] - 子节点字段
1795
- * @returns {any} 找到的节点;未找到返回 `undefined`
1795
+ * @returns {T | undefined} 找到的节点;未找到返回 `undefined`
1796
1796
  */
1797
- const findTreeNodeById = function findTreeNodeByIdFn(id, arr, idKey = "id", childrenKey = "children") {
1797
+ function findTreeNodeById(id, arr, idKey = "id", childrenKey = "children") {
1798
1798
  if (Array.isArray(arr) && arr.length > 0) {
1799
1799
  for (let i = 0; i < arr.length; i++) {
1800
1800
  const item = arr[i];
1801
1801
  if (item[idKey]?.toString() === id?.toString()) {
1802
1802
  return item;
1803
1803
  } else if (Array.isArray(item[childrenKey]) && item[childrenKey].length > 0) {
1804
- const result = findTreeNodeByIdFn(id, item[childrenKey], idKey, childrenKey);
1804
+ const result = findTreeNodeById(id, item[childrenKey], idKey, childrenKey);
1805
1805
  if (result) {
1806
1806
  return result;
1807
1807
  }
1808
1808
  }
1809
1809
  }
1810
1810
  }
1811
- };
1811
+ }
1812
1812
 
1813
1813
  /**
1814
1814
  * 在嵌套树中按 `id` 递归查找节点,并返回其指定属性值。