MCPcopy Index your code
hub / github.com/TanStack/table / accessRows

Function accessRows

packages/table-core/src/utils/getCoreRowModel.ts:24–72  ·  view source on GitHub ↗
(
          originalRows: TData[],
          depth = 0,
          parentRow?: Row<TData>,
        )

Source from the content-addressed store, hash-verified

22 }
23
24 const accessRows = (
25 originalRows: TData[],
26 depth = 0,
27 parentRow?: Row<TData>,
28 ): Row<TData>[] => {
29 const rows = [] as Row<TData>[]
30
31 for (let i = 0; i < originalRows.length; i++) {
32 // This could be an expensive check at scale, so we should move it somewhere else, but where?
33 // if (!id) {
34 // if (process.env.NODE_ENV !== 'production') {
35 // throw new Error(`getRowId expected an ID, but got ${id}`)
36 // }
37 // }
38
39 // Make the row
40 const row = createRow(
41 table,
42 table._getRowId(originalRows[i]!, i, parentRow),
43 originalRows[i]!,
44 i,
45 depth,
46 undefined,
47 parentRow?.id,
48 )
49
50 // Keep track of every row in a flat array
51 rowModel.flatRows.push(row)
52 // Also keep track of every row by its ID
53 rowModel.rowsById[row.id] = row
54 // Push table row into parent
55 rows.push(row)
56
57 // Get the original subrows
58 if (table.options.getSubRows) {
59 row.originalSubRows = table.options.getSubRows(
60 originalRows[i]!,
61 i,
62 )
63
64 // Then recursively access them
65 if (row.originalSubRows?.length) {
66 row.subRows = accessRows(row.originalSubRows, depth + 1, row)
67 }
68 }
69 }
70
71 return rows
72 }
73
74 rowModel.rows = accessRows(data)
75

Callers 1

getCoreRowModelFunction · 0.85

Calls 1

createRowFunction · 0.90

Tested by

no test coverage detected