Skip to content

Commit 9e5dba0

Browse files
committed
Fix supportedFunctions() missing 'SUMIF', 'AVERAGEIF'.
1 parent cc7efc5 commit 9e5dba0

File tree

4 files changed

+9
-10
lines changed

4 files changed

+9
-10
lines changed

formulas/functions/information.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ const InfoFunctions = {
2121
},
2222

2323
INFO: () => {
24-
throw FormulaError.NOT_IMPLEMENTED('INFO');
2524
},
2625

2726
ISBLANK: (value) => {

formulas/functions/text.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,7 @@ const TextFunctions = {
219219
return leftParenOrMinus ? -number : number;
220220
},
221221

222-
PHONETIC: (...params) => {
223-
throw FormulaError.NOT_IMPLEMENTED('PHONETIC');
222+
PHONETIC: () => {
224223
},
225224

226225
PROPER: (text) => {

grammar/hooks.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -216,16 +216,13 @@ class FormulaParser {
216216
const supported = [];
217217
const functions = Object.keys(this.functions);
218218
functions.forEach(fun => {
219-
let res;
220219
try {
221-
res = this.functions[fun](0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
220+
const res = this.functions[fun](0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
222221
if (res === undefined) return;
223222
supported.push(fun);
224223
} catch (e) {
225-
if (e instanceof FormulaError || e instanceof TypeError)
224+
if (e instanceof Error)
226225
supported.push(fun);
227-
// else
228-
// console.log(e)
229226
}
230227
});
231228
return supported.sort();

test/test.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,12 @@ describe('Parsing Formulas 2', () => {
9393
});
9494

9595
describe('Get supported formulas', () => {
96-
const number = parser.supportedFunctions().length;
97-
expect(number).to.greaterThan(200);
96+
const functionsNames = parser.supportedFunctions();
97+
expect(functionsNames.length).to.greaterThan(275);
98+
console.log(`Support ${functionsNames.length} functions:\n${functionsNames.join(', ')}`);
99+
expect(functionsNames.includes('IFNA')).to.eq(true);
100+
expect(functionsNames.includes('SUMIF')).to.eq(true);
101+
98102
})
99103

100104
require('./grammar/test');

0 commit comments

Comments
 (0)