Skip to content

Commit

Permalink
Remove for loops
Browse files Browse the repository at this point in the history
  • Loading branch information
Blakko committed Jun 12, 2024
1 parent ba21b3a commit 9e02022
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions packages/core/src/util/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,8 @@ export const dataValidation = (data?: GraphData | TreeGraphData): boolean => {

// 3. 边的 source 和 target 必须存在于节点 或 Combo中
const ids = new Set<string>();
if (nodes && (nodes as NodeConfig[]).length) {
for (let i = 0; i < (nodes as NodeConfig[]).length; i++) {
ids.add(nodes[i].id);
}
}
if ((combos as ComboConfig[]).length) {
for (let i = 0; i < (combos as ComboConfig[]).length; i++) {
ids.add(combos[i].id);
}
}
((nodes as NodeConfig[]) || []).forEach(node => ids.add(node.id));
((nodes as ComboConfig[]) || []).forEach(combo => ids.add(combo.id));
const nonEdges = ((edges as EdgeConfig[]) || []).find(function (edge) {
return !ids.has(edge.source) || !ids.has(edge.target);
});
Expand Down

0 comments on commit 9e02022

Please sign in to comment.