spreadsheet
typeScript/javascript spreadsheet parser, with formulas.
git clone https://git.vogt.world/spreadsheet.git
Log | Files | README.md
← Commit log
commit
message
Adding src/SupportedFormulas.ts, givng npm a test command
author
Ben Vogt <[email protected]>
date
2016-12-31 21:24:13
stats
3 file(s) changed, 26 insertions(+), 22 deletions(-)
files
package.json
src/Sheet.ts
src/SupportedFormulas.ts
 1diff --git a/package.json b/package.json
 2index 6f98f8a..0ecc326 100644
 3--- a/package.json
 4+++ b/package.json
 5@@ -4,7 +4,7 @@
 6   "description": "TypeScript implementation of a spreadsheet.",
 7   "scripts": {
 8     "build": "tsc && cp lib/parser.js output/",
 9-    "test": "tsc --outDir test_output tests/*.ts && "
10+    "test": "./tests.sh"
11   },
12   "author": "vogtb <bvogt at gmail.com>",
13   "license": "MIT",
14diff --git a/src/Sheet.ts b/src/Sheet.ts
15index 5db49f2..939a503 100644
16--- a/src/Sheet.ts
17+++ b/src/Sheet.ts
18@@ -1,6 +1,7 @@
19 /// <reference path="parser.d.ts"/>
20 import { Parser } from "./Parser";
21 import { A1CellKey } from "./A1CellKey"
22+import { SUPPORTED_FORMULAS } from "./SupportedFormulas"
23 import { Cell } from "./Cell"
24 import { Errors } from "./Errors"
25 import * as Formula from "formulajs"
26@@ -285,25 +286,6 @@ var Sheet = (function () {
27   };
28 
29   var helper = {
30-    SUPPORTED_FORMULAS: [
31-      'ABS', 'ACCRINT', 'ACOS', 'ACOSH', 'ACOTH', 'AND', 'ARABIC', 'ASIN', 'ASINH', 'ATAN', 'ATAN2', 'ATANH', 'AVEDEV', 'AVERAGE', 'AVERAGEA', 'AVERAGEIF',
32-      'BASE', 'BESSELI', 'BESSELJ', 'BESSELK', 'BESSELY', 'BETADIST', 'BETAINV', 'BIN2DEC', 'BIN2HEX', 'BIN2OCT', 'BINOMDIST', 'BINOMDISTRANGE', 'BINOMINV', 'BITAND', 'BITLSHIFT', 'BITOR', 'BITRSHIFT', 'BITXOR',
33-      'CEILING', 'CEILINGMATH', 'CEILINGPRECISE', 'CHAR', 'CHISQDIST', 'CHISQINV', 'CODE', 'COMBIN', 'COMBINA', 'COMPLEX', 'CONCATENATE', 'CONFIDENCENORM', 'CONFIDENCET', 'CONVERT', 'CORREL', 'COS', 'COSH', 'COT', 'COTH', 'COUNT', 'COUNTA', 'COUNTBLANK', 'COUNTIF', 'COUNTIFS', 'COUNTIN', 'COUNTUNIQUE', 'COVARIANCEP', 'COVARIANCES', 'CSC', 'CSCH', 'CUMIPMT', 'CUMPRINC',
34-      'DATE', 'DATEVALUE', 'DAY', 'DAYS', 'DAYS360', 'DB', 'DDB', 'DEC2BIN', 'DEC2HEX', 'DEC2OCT', 'DECIMAL', 'DEGREES', 'DELTA', 'DEVSQ', 'DOLLAR', 'DOLLARDE', 'DOLLARFR',
35-      'E', 'EDATE', 'EFFECT', 'EOMONTH', 'ERF', 'ERFC', 'EVEN', 'EXACT', 'EXPONDIST',
36-      'FALSE', 'FDIST', 'FINV', 'FISHER', 'FISHERINV',
37-      'IF', 'INT', 'ISEVEN', 'ISODD',
38-      'LN', 'LOG', 'LOG10',
39-      'MAX', 'MAXA', 'MEDIAN', 'MIN', 'MINA', 'MOD',
40-      'NOT',
41-      'ODD', 'OR',
42-      'PI', 'POWER',
43-      'ROUND', 'ROUNDDOWN', 'ROUNDUP',
44-      'SIN', 'SINH', 'SPLIT', 'SQRT', 'SQRTPI', 'SUM', 'SUMIF', 'SUMIFS', 'SUMPRODUCT', 'SUMSQ', 'SUMX2MY2', 'SUMX2PY2', 'SUMXMY2',
45-      'TAN', 'TANH', 'TRUE', 'TRUNC',
46-      'XOR'
47-    ],
48-
49     number: function (num) {
50       switch (typeof num) {
51         case 'number':
52@@ -412,7 +394,7 @@ var Sheet = (function () {
53       fn = fn.toUpperCase();
54       args = args || [];
55 
56-      if (instance.helper.SUPPORTED_FORMULAS.indexOf(fn) > -1) {
57+      if (SUPPORTED_FORMULAS.indexOf(fn) > -1) {
58         if (Formula[fn]) {
59           return Formula[fn].apply(this, args);
60         }
61diff --git a/src/SupportedFormulas.ts b/src/SupportedFormulas.ts
62new file mode 100644
63index 0000000..8ff2865
64--- /dev/null
65+++ b/src/SupportedFormulas.ts
66@@ -0,0 +1,22 @@
67+const SUPPORTED_FORMULAS = [
68+  'ABS', 'ACCRINT', 'ACOS', 'ACOSH', 'ACOTH', 'AND', 'ARABIC', 'ASIN', 'ASINH', 'ATAN', 'ATAN2', 'ATANH', 'AVEDEV', 'AVERAGE', 'AVERAGEA', 'AVERAGEIF',
69+  'BASE', 'BESSELI', 'BESSELJ', 'BESSELK', 'BESSELY', 'BETADIST', 'BETAINV', 'BIN2DEC', 'BIN2HEX', 'BIN2OCT', 'BINOMDIST', 'BINOMDISTRANGE', 'BINOMINV', 'BITAND', 'BITLSHIFT', 'BITOR', 'BITRSHIFT', 'BITXOR',
70+  'CEILING', 'CEILINGMATH', 'CEILINGPRECISE', 'CHAR', 'CHISQDIST', 'CHISQINV', 'CODE', 'COMBIN', 'COMBINA', 'COMPLEX', 'CONCATENATE', 'CONFIDENCENORM', 'CONFIDENCET', 'CONVERT', 'CORREL', 'COS', 'COSH', 'COT', 'COTH', 'COUNT', 'COUNTA', 'COUNTBLANK', 'COUNTIF', 'COUNTIFS', 'COUNTIN', 'COUNTUNIQUE', 'COVARIANCEP', 'COVARIANCES', 'CSC', 'CSCH', 'CUMIPMT', 'CUMPRINC',
71+  'DATE', 'DATEVALUE', 'DAY', 'DAYS', 'DAYS360', 'DB', 'DDB', 'DEC2BIN', 'DEC2HEX', 'DEC2OCT', 'DECIMAL', 'DEGREES', 'DELTA', 'DEVSQ', 'DOLLAR', 'DOLLARDE', 'DOLLARFR',
72+  'E', 'EDATE', 'EFFECT', 'EOMONTH', 'ERF', 'ERFC', 'EVEN', 'EXACT', 'EXPONDIST',
73+  'FALSE', 'FDIST', 'FINV', 'FISHER', 'FISHERINV',
74+  'IF', 'INT', 'ISEVEN', 'ISODD',
75+  'LN', 'LOG', 'LOG10',
76+  'MAX', 'MAXA', 'MEDIAN', 'MIN', 'MINA', 'MOD',
77+  'NOT',
78+  'ODD', 'OR',
79+  'PI', 'POWER',
80+  'ROUND', 'ROUNDDOWN', 'ROUNDUP',
81+  'SIN', 'SINH', 'SPLIT', 'SQRT', 'SQRTPI', 'SUM', 'SUMIF', 'SUMIFS', 'SUMPRODUCT', 'SUMSQ', 'SUMX2MY2', 'SUMX2PY2', 'SUMXMY2',
82+  'TAN', 'TANH', 'TRUE', 'TRUNC',
83+  'XOR'
84+];
85+
86+export {
87+  SUPPORTED_FORMULAS
88+}
89\ No newline at end of file