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.
- package/dist/a2bei4.utils.cjs.js +4 -4
- package/dist/a2bei4.utils.cjs.js.map +1 -1
- package/dist/a2bei4.utils.cjs.min.js +1 -1
- package/dist/a2bei4.utils.cjs.min.js.map +1 -1
- package/dist/a2bei4.utils.esm.js +4 -4
- package/dist/a2bei4.utils.esm.js.map +1 -1
- package/dist/a2bei4.utils.esm.min.js +1 -1
- package/dist/a2bei4.utils.esm.min.js.map +1 -1
- package/dist/a2bei4.utils.umd.js +4 -4
- package/dist/a2bei4.utils.umd.js.map +1 -1
- package/dist/a2bei4.utils.umd.min.js +1 -1
- package/dist/a2bei4.utils.umd.min.js.map +1 -1
- package/dist/tree.cjs +4 -4
- package/dist/tree.cjs.map +1 -1
- package/dist/tree.js +4 -4
- package/dist/tree.js.map +1 -1
- package/package.json +1 -1
- package/types/index.d.ts +11 -1
- package/types/tree.d.ts +11 -1
package/dist/a2bei4.utils.umd.js
CHANGED
|
@@ -1798,23 +1798,23 @@ registerProcessor('audio-stream-resampler-processor', AudioStreamResamplerProces
|
|
|
1798
1798
|
* @param {T[]} arr - 嵌套树森林
|
|
1799
1799
|
* @param {string} [idKey='id'] - 主键字段
|
|
1800
1800
|
* @param {string} [childrenKey='children'] - 子节点字段
|
|
1801
|
-
* @returns {
|
|
1801
|
+
* @returns {T | undefined} 找到的节点;未找到返回 `undefined`
|
|
1802
1802
|
*/
|
|
1803
|
-
|
|
1803
|
+
function findTreeNodeById(id, arr, idKey = "id", childrenKey = "children") {
|
|
1804
1804
|
if (Array.isArray(arr) && arr.length > 0) {
|
|
1805
1805
|
for (let i = 0; i < arr.length; i++) {
|
|
1806
1806
|
const item = arr[i];
|
|
1807
1807
|
if (item[idKey]?.toString() === id?.toString()) {
|
|
1808
1808
|
return item;
|
|
1809
1809
|
} else if (Array.isArray(item[childrenKey]) && item[childrenKey].length > 0) {
|
|
1810
|
-
const result =
|
|
1810
|
+
const result = findTreeNodeById(id, item[childrenKey], idKey, childrenKey);
|
|
1811
1811
|
if (result) {
|
|
1812
1812
|
return result;
|
|
1813
1813
|
}
|
|
1814
1814
|
}
|
|
1815
1815
|
}
|
|
1816
1816
|
}
|
|
1817
|
-
}
|
|
1817
|
+
}
|
|
1818
1818
|
|
|
1819
1819
|
/**
|
|
1820
1820
|
* 在嵌套树中按 `id` 递归查找节点,并返回其指定属性值。
|