Skip to content

Commit

Permalink
Cell -> CellType
Browse files Browse the repository at this point in the history
  • Loading branch information
miya committed Jan 14, 2024
1 parent 79cd32f commit 4f459eb
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/CalcMethod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const MethodTypes = Object.values(MethodType);

export type MethodType = (typeof MethodType)[keyof typeof MethodType];

type Cell = 'row' | 'column';
type CellType = 'row' | 'column';

type Pos = { row: number; column: number };

Expand Down Expand Up @@ -56,16 +56,16 @@ const convertToCalculableValues = (values: any[]): number[] => {
return values.map((v) => convertToNumber(v)).filter((v) => v != null) as number[];
};

const getTargetCells = (api: DataTableApi<any>, cell: Cell, pos: Pos): any => {
if (cell === 'row') {
const getTargetCells = (api: DataTableApi<any>, cellType: CellType, pos: Pos): any => {
if (cellType === 'row') {
return api.row(pos.row).data();
}
if (cell === 'column') {
if (cellType === 'column') {
return api.column(pos.column).data().toArray();
}
};

const createCalcMethod = (cell: Cell, calculator: (values: number[]) => number): CalcMethod['calcMethod'] => {
const createCalcMethod = (cell: CellType, calculator: (values: number[]) => number): CalcMethod['calcMethod'] => {
return (api: DataTableApi<any>, pos: Pos) => {
const targetCells = getTargetCells(api, cell, pos);
const calculableValues = convertToCalculableValues(targetCells);
Expand Down

0 comments on commit 4f459eb

Please sign in to comment.