* Returns a single row of the data or a subset of its columns. If a column range or `toArray` arguments are provided, it * operates only on the columns declared by the `columns` setting or the data schema. * * @param {number} row Physical row index. * @param {number} [startColumn] Starti
(row: number, startColumn?: number, endColumn?: number, toArray = false)
| 142 | * @returns {Array|object} |
| 143 | */ |
| 144 | getAtRow(row: number, startColumn?: number, endColumn?: number, toArray = false) { |
| 145 | const getAllProps = startColumn === undefined && endColumn === undefined; |
| 146 | const { dataDotNotation } = this.hot!.getSettings(); |
| 147 | let dataRow = null; |
| 148 | let newDataRow: Record<string | number, unknown> | null = null; |
| 149 | |
| 150 | dataRow = this.modifyRowData(row); |
| 151 | |
| 152 | if (Array.isArray(dataRow)) { |
| 153 | newDataRow = [] as unknown as Record<string | number, unknown>; |
| 154 | |
| 155 | if (getAllProps) { |
| 156 | dataRow.forEach((cell: unknown, column: number) => { |
| 157 | newDataRow![column] = this.getAtPhysicalCell(row, column, dataRow); |
| 158 | }); |
| 159 | |
| 160 | } else { |
| 161 | // Only the columns from the provided range |
| 162 | rangeEach(startColumn!, endColumn!, (column: number) => { |
| 163 | newDataRow![column - startColumn!] = this.getAtPhysicalCell(row, column, dataRow); |
| 164 | }); |
| 165 | } |
| 166 | |
| 167 | } else if (isObject(dataRow) || isFunction(dataRow)) { |
| 168 | if (toArray) { |
| 169 | newDataRow = [] as unknown as Record<string | number, unknown>; |
| 170 | } else { |
| 171 | newDataRow = {}; |
| 172 | } |
| 173 | |
| 174 | if (!getAllProps || toArray) { |
| 175 | const rangeStart = 0; |
| 176 | const rangeEnd = this.countFirstRowKeys() - 1; |
| 177 | |
| 178 | rangeEach(rangeStart, rangeEnd, (column: number) => { |
| 179 | const prop = this.colToProp(column); |
| 180 | |
| 181 | if (column >= (startColumn || rangeStart) && column <= (endColumn || rangeEnd) && !Number.isInteger(prop)) { |
| 182 | const cellValue = this.getAtPhysicalCell(row, prop as string | number | DataAccessorFn, dataRow); |
| 183 | |
| 184 | if (toArray) { |
| 185 | (newDataRow as unknown as unknown[]).push(cellValue); |
| 186 | |
| 187 | } else if (dataDotNotation) { |
| 188 | if (newDataRow !== null) { |
| 189 | setProperty(newDataRow as Record<string, unknown>, prop as string, cellValue); |
| 190 | } |
| 191 | |
| 192 | } else { |
| 193 | newDataRow![prop as string] = cellValue; |
| 194 | } |
| 195 | } |
| 196 | }); |
| 197 | |
| 198 | } else { |
| 199 | objectEach(dataRow as Record<string, unknown>, (value: unknown, prop: string) => { |
| 200 | const cellValue = this.getAtPhysicalCell(row, prop, dataRow); |
| 201 |
no test coverage detected