Skip to content

Commit 140b5a4

Browse files
committed
cleaning up code
1 parent 68a44b1 commit 140b5a4

File tree

1 file changed

+5
-9
lines changed
  • packages/components/src/components/hds/advanced-table/models

1 file changed

+5
-9
lines changed

packages/components/src/components/hds/advanced-table/models/table.ts

+5-9
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ function getVisibleRows(rows: HdsAdvancedTableRow[]): HdsAdvancedTableRow[] {
2323
}, [] as HdsAdvancedTableRow[]);
2424
}
2525

26+
function getChildrenCount(rows: HdsAdvancedTableRow[]): number {
27+
return rows.reduce((acc, row) => acc + 1 + getChildrenCount(row.children), 0);
28+
}
29+
2630
export default class HdsAdvancedTableTableModel {
2731
rows: HdsAdvancedTableRow[] = [];
2832

@@ -35,15 +39,7 @@ export default class HdsAdvancedTableTableModel {
3539
}
3640

3741
get totalRowCount(): number {
38-
function getChildrenCount(rows: HdsAdvancedTableRow[]): number {
39-
return rows.reduce((acc, row) => {
40-
return acc + 1 + getChildrenCount(row.children);
41-
}, 0);
42-
}
43-
44-
return this.rows.reduce((acc, row) => {
45-
return acc + 1 + getChildrenCount(row.children);
46-
}, 0);
42+
return getChildrenCount(this.rows);
4743
}
4844

4945
get flattenedVisibleRows(): HdsAdvancedTableRow[] {

0 commit comments

Comments
 (0)