18 lines
450 B
TypeScript
18 lines
450 B
TypeScript
|
import type { TableItem } from "./types";
|
||
|
|
||
|
export function getColumn(row: TableItem, colName: string) {
|
||
|
return row[colName];
|
||
|
}
|
||
|
|
||
|
export function forEachCols(rows: TableItem[], func: Function) {
|
||
|
rows.forEach((row: TableItem) => {
|
||
|
for (const colName in row) {
|
||
|
if (Object.prototype.hasOwnProperty.call(row, colName)) {
|
||
|
if (getColumn(row, colName)) {
|
||
|
func(colName, getColumn(row, colName));
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
}
|