feat: insert csv columns

This commit is contained in:
Chesterkxng
2025-05-24 02:50:38 +02:00
parent a53dfc7c15
commit a2f63664b0
8 changed files with 539 additions and 3 deletions

View File

@@ -12,10 +12,17 @@ export function transpose<T>(matrix: T[][]): any[][] {
* Normalize and fill a 2D array to ensure all rows have the same length.
* @param {any[][]} matrix - The 2D array to normalize and fill.
* @param {any} fillValue - The value to fill in for missing elements.
* @param {number} desiredLength - The target length of the array. if given take it as maxLength.
* @returns {any[][]} - The normalized and filled 2D array.
* **/
export function normalizeAndFill<T>(matrix: T[][], fillValue: T): T[][] {
const maxLength = Math.max(...matrix.map((row) => row.length));
export function normalizeAndFill<T>(
matrix: T[][],
fillValue: T,
desiredLength?: number
): T[][] {
const maxLength = !desiredLength
? Math.max(...matrix.map((row) => row.length))
: desiredLength;
return matrix.map((row) => {
const filledRow = [...row];
while (filledRow.length < maxLength) {