spreadsheet
typeScript/javascript spreadsheet parser, with formulas.
git clone https://git.vogt.world/spreadsheet.git
Log | Files | README.md
← Commit log
commit
message
WIP on bootstrapping formula functions in so I can rewrite them with greater ease
author
Ben Vogt <[email protected]>
date
2017-01-14 21:45:03
stats
3 file(s) changed, 21 insertions(+), 0 deletions(-)
files
src/Formulas.ts
src/RawFormulas.ts
tests/FormulasTest.ts
 1diff --git a/src/Formulas.ts b/src/Formulas.ts
 2index 5b9063a..aab1a73 100644
 3--- a/src/Formulas.ts
 4+++ b/src/Formulas.ts
 5@@ -1,6 +1,7 @@
 6 /// <reference path="../node_modules/moment/moment.d.ts"/>
 7 import * as moment from "moment";
 8 import * as Formula from "formulajs"
 9+import * as RawFormulas from "./RawFormulas";
10 
11 const SUPPORTED_FORMULAS = [
12   'ABS', 'ACCRINT', 'ACOS', 'ACOSH', 'ACOTH', 'AND', 'ARABIC', 'ASIN', 'ASINH', 'ATAN', 'ATAN2', 'ATANH', 'AVEDEV', 'AVERAGE', 'AVERAGEA', 'AVERAGEIF',
13@@ -22,6 +23,7 @@ const SUPPORTED_FORMULAS = [
14 ];
15 
16 const CustomFormulas = {
17+  ABS: RawFormulas.ABS,
18   "F.DIST": Formula["FDIST"],
19   "F.INV": Formula["FINV"],
20   ATAN2: function (x, y) {
21diff --git a/src/RawFormulas.ts b/src/RawFormulas.ts
22new file mode 100644
23index 0000000..33f661b
24--- /dev/null
25+++ b/src/RawFormulas.ts
26@@ -0,0 +1,10 @@
27+import * as Formula from "formulajs"
28+
29+var ABS = Formula["ABS"];
30+var ACOS = Formula["ACOS"];
31+
32+
33+export {
34+  ABS,
35+  ACOS
36+}
37\ No newline at end of file
38diff --git a/tests/FormulasTest.ts b/tests/FormulasTest.ts
39new file mode 100644
40index 0000000..d680dfb
41--- /dev/null
42+++ b/tests/FormulasTest.ts
43@@ -0,0 +1,9 @@
44+import { ABS, ACOS } from "../src/RawFormulas"
45+import { assertEquals } from "./utils/Asserts"
46+
47+// Test ABS formula
48+assertEquals(ABS(-10), 10);
49+assertEquals(ABS(0), 0);
50+
51+// Test ACOS formula
52+assertEquals(ACOS(0), 1.5707963267948966);