修复 someTree 逻辑问题

This commit is contained in:
2betop 2020-06-18 20:03:38 +08:00
parent 39bc57068a
commit f70c2bb155

View File

@ -929,7 +929,17 @@ export function someTree<T extends TreeItem>(
tree: Array<T>,
iterator: (item: T, key: number, level: number, paths: Array<T>) => boolean
): boolean {
return !everyTree(tree, iterator);
let result = false;
everyTree(tree, (item: T, key: number, level: number, paths: Array<T>) => {
if (iterator(item, key, level, paths)) {
result = true;
return false;
}
return true;
});
return result;
}
/**