mirror of
https://github.com/iib0011/omni-tools.git
synced 2025-09-19 22:19:36 +02:00
feat: insert csv columns
This commit is contained in:
@@ -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) {
|
||||
|
Reference in New Issue
Block a user