( table: MarkdownTable, index: number, align: ColumnAlign = 'none' )
| 317 | |
| 318 | /** Insert an empty column at `index` (clamped) with the given alignment. */ |
| 319 | export function insertColumn( |
| 320 | table: MarkdownTable, |
| 321 | index: number, |
| 322 | align: ColumnAlign = 'none' |
| 323 | ): MarkdownTable { |
| 324 | const next = clone(table) |
| 325 | const at = Math.max(0, Math.min(index, columnCount(next))) |
| 326 | next.headers.splice(at, 0, '') |
| 327 | next.aligns.splice(at, 0, align) |
| 328 | for (const row of next.rows) row.splice(at, 0, '') |
| 329 | return next |
| 330 | } |
| 331 | |
| 332 | export function deleteColumn(table: MarkdownTable, index: number): MarkdownTable { |
| 333 | if (index < 0 || index >= columnCount(table)) return table |
no test coverage detected