spreadsheet
typeScript/javascript spreadsheet parser, with formulas.
git clone https://git.vogt.world/spreadsheet.git
Log | Files | README.md
← Commit log
commit
message
More formulas as RawFormulas
author
Ben Vogt <[email protected]>
date
2017-01-14 22:07:26
stats
2 file(s) changed, 141 insertions(+), 0 deletions(-)
files
src/RawFormulas.ts
tests/FormulasTest.ts
  1diff --git a/src/RawFormulas.ts b/src/RawFormulas.ts
  2index c367af7..197679e 100644
  3--- a/src/RawFormulas.ts
  4+++ b/src/RawFormulas.ts
  5@@ -19,6 +19,42 @@ var AVERAGEA = Formula["AVERAGEA"];
  6 var AVERAGEIF = Formula["AVERAGEIF"];
  7 var BASE = Formula["BASE"];
  8 var BIN2DEC = Formula["BIN2DEC"];
  9+var BESSELI = Formula["BESSELI"];
 10+var BESSELJ = Formula["BESSELJ"];
 11+var BESSELK = Formula["BESSELK"];
 12+var BESSELY = Formula["BESSELY"];
 13+var BETADIST = Formula["BETADIST"];
 14+var BETAINV = Formula["BETAINV"];
 15+var BITAND = Formula["BITAND"];
 16+var BITLSHIFT = Formula["BITLSHIFT"];
 17+var BITOR = Formula["BITOR"];
 18+var BITRSHIFT = Formula["BITRSHIFT"];
 19+var BITXOR = Formula["BITXOR"];
 20+var BIN2HEX = Formula["BIN2HEX"];
 21+var BIN2OCT = Formula["BIN2OCT"];
 22+var DECIMAL = Formula["DECIMAL"];
 23+var CEILING = Formula["CEILING"];
 24+var CEILINGMATH = Formula["CEILINGMATH"];
 25+var CEILINGPRECISE = Formula["CEILINGPRECISE"];
 26+var CHAR = Formula["CHAR"];
 27+var CODE = Formula["CODE"];
 28+var COMBIN = Formula["COMBIN"];
 29+var COMBINA = Formula["COMBINA"];
 30+var COMPLEX = Formula["COMPLEX"];
 31+var CONCATENATE = Formula["CONCATENATE"];
 32+var CONVERT = Formula["CONVERT"];
 33+var CORREL = Formula["CORREL"];
 34+var COS = Formula["COS"];
 35+var PI = function () {
 36+  return Math.PI;
 37+};
 38+var COSH = Formula["COSH"];
 39+var COT = Formula["COT"];
 40+var COTH = Formula["COTH"];
 41+var COUNT = Formula["COUNT"];
 42+var COUNTA = Formula["COUNTA"];
 43+var COUNTIF = Formula["COUNTIF"];
 44+var COUNTIFS = Formula["COUNTIFS"];
 45 
 46 export {
 47   ABS,
 48@@ -37,5 +73,39 @@ export {
 49   AVERAGEA,
 50   AVERAGEIF,
 51   BASE,
 52-  BIN2DEC
 53+  BIN2DEC,
 54+  BESSELI,
 55+  BESSELJ,
 56+  BESSELK,
 57+  BESSELY,
 58+  BETADIST,
 59+  BETAINV,
 60+  BITAND,
 61+  BITLSHIFT,
 62+  BITOR,
 63+  BITRSHIFT,
 64+  BITXOR,
 65+  BIN2HEX,
 66+  BIN2OCT,
 67+  DECIMAL,
 68+  CEILING,
 69+  CEILINGMATH,
 70+  CEILINGPRECISE,
 71+  CHAR,
 72+  CODE,
 73+  COMBIN,
 74+  COMBINA,
 75+  COMPLEX,
 76+  CONCATENATE,
 77+  CONVERT,
 78+  CORREL,
 79+  COS,
 80+  PI,
 81+  COSH,
 82+  COT,
 83+  COTH,
 84+  COUNT,
 85+  COUNTA,
 86+  COUNTIF,
 87+  COUNTIFS
 88 }
 89\ No newline at end of file
 90diff --git a/tests/FormulasTest.ts b/tests/FormulasTest.ts
 91index d0c0864..ff94a7c 100644
 92--- a/tests/FormulasTest.ts
 93+++ b/tests/FormulasTest.ts
 94@@ -1,5 +1,8 @@
 95 import { ABS, ACOS, ACOSH, ACOTH, AND, ARABIC, ASIN, ASINH, ATAN, ATAN2, ATANH, AVEDEV, AVERAGE,
 96-  AVERAGEA, AVERAGEIF, BASE, BIN2DEC } from "../src/RawFormulas"
 97+    AVERAGEA, AVERAGEIF, BASE, BIN2DEC, BESSELI, BESSELJ, BESSELK, BESSELY, BETADIST, BETAINV,
 98+    BITAND, BITLSHIFT, BITOR, BITRSHIFT, BITXOR, BIN2HEX, BIN2OCT, DECIMAL, CEILING,
 99+    CEILINGMATH, CEILINGPRECISE, CHAR, CODE, COMBIN, COMBINA, COMPLEX, CONCATENATE, CONVERT,
100+    CORREL, COS, PI, COSH, COT, COTH, COUNT, COUNTA, COUNTIF, COUNTIFS } from "../src/RawFormulas"
101 import { assertEquals } from "./utils/Asserts"
102 
103 assertEquals(ABS(-10), 10);
104@@ -37,3 +40,69 @@ assertEquals(AVERAGEIF([1, 5, 10], '>2'), 7.5);
105 assertEquals(BASE(15, 2, 10), '0000001111');
106 
107 assertEquals(BIN2DEC(1010101010), -342);
108+
109+assertEquals(BESSELI(1, 2), 0.13574766658069928);
110+
111+assertEquals(BESSELJ(1, 2), 0.11490348499246938);
112+
113+assertEquals(BESSELK(1, 2), 1.6248388844172295);
114+
115+assertEquals(BESSELY(1, 2), -1.6506826133039476);
116+
117+assertEquals(BETADIST(2, 8, 10, true, 1, 3), 0.6854705810117458);
118+
119+assertEquals(BETAINV(0.6854705810117458, 8, 10, 1, 3), 1.9999999999999996);
120+
121+assertEquals(BITAND(42, 24), 8);
122+
123+assertEquals(BITLSHIFT(42, 24), 704643072);
124+
125+assertEquals(BITOR(42, 24), 58);
126+
127+assertEquals(BITRSHIFT(42, 2), 10);
128+
129+assertEquals(BITXOR(42, 24), 50);
130+
131+assertEquals(BIN2HEX(1010101010), "fffffffeaa");
132+
133+assertEquals(BIN2OCT(1010101010), "7777777252");
134+
135+assertEquals(DECIMAL(199.99999), 199);
136+
137+assertEquals(CEILING(22.22, 0.1), 22.3);
138+
139+assertEquals(CEILINGMATH(1001.112131), 1002);
140+
141+assertEquals(CEILINGPRECISE(1001.112131), 1002);
142+
143+assertEquals(CHAR(97), "a");
144+
145+assertEquals(CODE('a'), 97);
146+
147+assertEquals(COMBIN(4, 2), 6);
148+
149+assertEquals(COMBINA(4, 3), 20);
150+
151+assertEquals(COMPLEX(3, 4), '3+4i');
152+
153+assertEquals(CONCATENATE("hey", " ", "there"), "hey there");
154+
155+assertEquals(CONVERT(5.1, "mm", "m"), 0.0050999999999999995);
156+
157+assertEquals(CORREL([9, 5],[10, 4]), 1);
158+
159+assertEquals(COS(PI()), -1);
160+
161+assertEquals(COSH(PI()), 11.591953275521522);
162+
163+assertEquals(COT(30), -0.15611995216165922);
164+
165+assertEquals(COTH(2), 1.0373147207275482);
166+
167+assertEquals(COUNT([1, 5, 10]), 3);
168+
169+assertEquals(COUNTA(10, 10, 22), 3);
170+
171+assertEquals(COUNTIF([1, 5, 10], ">4"), 2);
172+
173+assertEquals(COUNTIFS([1, 5, 10], ">4", [1, 5, 10], ">4"), 2);