* Builds the column property cache from the `columns` setting. * * @param {Function|Array} columns The columns setting value. * @param {unknown} schema The current data schema.
(
columns: ((column: number) => Record<string, unknown>) | Record<string, unknown>[],
schema: unknown
)
| 180 | * @param {unknown} schema The current data schema. |
| 181 | */ |
| 182 | #buildColumnCache( |
| 183 | columns: ((column: number) => Record<string, unknown>) | Record<string, unknown>[], |
| 184 | schema: unknown |
| 185 | ) { |
| 186 | let columnsLen = 0; |
| 187 | let filteredIndex = 0; |
| 188 | const isColumnsFn = typeof columns === 'function'; |
| 189 | |
| 190 | if (isColumnsFn) { |
| 191 | const schemaLen = deepObjectSize(schema); |
| 192 | |
| 193 | columnsLen = schemaLen > 0 ? schemaLen : this.countFirstRowKeys(); |
| 194 | |
| 195 | } else { |
| 196 | const maxCols = this.tableMeta.maxCols; |
| 197 | |
| 198 | columnsLen = Math.min(maxCols ?? Infinity, columns.length); |
| 199 | } |
| 200 | |
| 201 | for (let i = 0; i < columnsLen; i++) { |
| 202 | const column = isColumnsFn |
| 203 | ? (columns as (index: number) => Record<string, unknown>)(i) : columns[i]; |
| 204 | |
| 205 | if (isObject(column)) { |
| 206 | if (typeof column.data !== 'undefined') { |
| 207 | const index = isColumnsFn ? filteredIndex : i; |
| 208 | const columnData = column.data as string | number; |
| 209 | |
| 210 | this.colToPropCache[index] = columnData; |
| 211 | this.propToColCache!.set(columnData, index); |
| 212 | } |
| 213 | |
| 214 | filteredIndex += 1; |
| 215 | } |
| 216 | } |
| 217 | } |
| 218 | |
| 219 | /** |
| 220 | * Get the amount of physical columns in the first data row. |
no test coverage detected