* Translates property into visual column index. * * @param {string|number} prop Column property which may be also a physical column index. * @returns {string|number} Visual column index or passed argument.
(prop: string | number)
| 290 | * @returns {string|number} Visual column index or passed argument. |
| 291 | */ |
| 292 | propToCol(prop: string | number) { |
| 293 | const cachedPhysicalIndex = this.propToColCache!.get(prop); |
| 294 | |
| 295 | if (cachedPhysicalIndex !== undefined) { |
| 296 | return this.hot!.toVisualColumn(cachedPhysicalIndex); |
| 297 | } |
| 298 | |
| 299 | // Property may be a physical column index. |
| 300 | if (typeof prop !== 'number') { |
| 301 | return prop; |
| 302 | } |
| 303 | |
| 304 | const visualColumn = this.hot!.toVisualColumn(prop); |
| 305 | |
| 306 | // Fall back to the physical index when toVisualColumn returns null |
| 307 | // (e.g. column is trimmed/hidden and has no visual equivalent). |
| 308 | return visualColumn !== null ? visualColumn : prop; |
| 309 | } |
| 310 | |
| 311 | /** |
| 312 | * Returns data's schema. |
no test coverage detected