Skip to content

Commit

Permalink
Fix supportedFunctions() missing 'SUMIF', 'AVERAGEIF'.
Browse files Browse the repository at this point in the history
  • Loading branch information
LesterLyu committed Aug 14, 2020
1 parent cc7efc5 commit 9e5dba0
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
1 change: 0 additions & 1 deletion formulas/functions/information.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ const InfoFunctions = {
},

INFO: () => {
throw FormulaError.NOT_IMPLEMENTED('INFO');
},

ISBLANK: (value) => {
Expand Down
3 changes: 1 addition & 2 deletions formulas/functions/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,7 @@ const TextFunctions = {
return leftParenOrMinus ? -number : number;
},

PHONETIC: (...params) => {
throw FormulaError.NOT_IMPLEMENTED('PHONETIC');
PHONETIC: () => {
},

PROPER: (text) => {
Expand Down
7 changes: 2 additions & 5 deletions grammar/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,16 +216,13 @@ class FormulaParser {
const supported = [];
const functions = Object.keys(this.functions);
functions.forEach(fun => {
let res;
try {
res = this.functions[fun](0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
const res = this.functions[fun](0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
if (res === undefined) return;
supported.push(fun);
} catch (e) {
if (e instanceof FormulaError || e instanceof TypeError)
if (e instanceof Error)
supported.push(fun);
// else
// console.log(e)
}
});
return supported.sort();
Expand Down
8 changes: 6 additions & 2 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,12 @@ describe('Parsing Formulas 2', () => {
});

describe('Get supported formulas', () => {
const number = parser.supportedFunctions().length;
expect(number).to.greaterThan(200);
const functionsNames = parser.supportedFunctions();
expect(functionsNames.length).to.greaterThan(275);
console.log(`Support ${functionsNames.length} functions:\n${functionsNames.join(', ')}`);
expect(functionsNames.includes('IFNA')).to.eq(true);
expect(functionsNames.includes('SUMIF')).to.eq(true);

})

require('./grammar/test');
Expand Down

0 comments on commit 9e5dba0

Please sign in to comment.