MCPcopy Create free account
hub / github.com/apitable/apitable / func

Method func

packages/core/src/formula_parser/functions/numeric.ts:110–132  ·  view source on GitHub ↗
(params: IFormulaParam<number>[])

Source from the content-addressed store, hash-verified

108 }
109
110 static override func(params: IFormulaParam<number>[]): number {
111 let result = 0;
112 // If there is only one parameter and it is an array, it means that the value of the array type field is summed
113 if (isArrayParam(params)) {
114 const innerValueType = (params[0].node as ValueOperandNodeBase).innerValueType;
115 if (innerValueType && innerValueType === BasicValueType.DateTime) {
116 return 0;
117 }
118 if (!params[0].value) {
119 return 0;
120 }
121
122 result = params[0].value.reduce((pre, cur) => {
123 return plus(pre, noNaN(Number(cur)));
124 }, 0);
125 } else {
126 result = params.reduce((pre, cur) => {
127 return plus(pre, noNaN(Number(cur.value)));
128 }, 0);
129 }
130
131 return result;
132 }
133}
134
135export class Abs extends NumericFunc {

Callers

nothing calls this directly

Calls 3

plusFunction · 0.90
noNaNFunction · 0.90
isArrayParamFunction · 0.70

Tested by

no test coverage detected