spreadsheet
typeScript/javascript spreadsheet parser, with formulas.
git clone https://git.vogt.world/spreadsheet.git
Log | Files | README.md
← Commit log
commit
message
[ISNUMBER] formula added and tested
author
Ben Vogt <[email protected]>
date
2017-06-16 00:20:45
stats
8 file(s) changed, 56 insertions(+), 6 deletions(-)
files
DOCS.md
TODO.md
dist/Formulas/AllFormulas.js
dist/Formulas/Info.js
src/Formulas/AllFormulas.ts
src/Formulas/Info.ts
tests/Formulas/InfoTest.ts
tests/SheetFormulaTest.ts
  1diff --git a/DOCS.md b/DOCS.md
  2index acf8f25..99293ee 100644
  3--- a/DOCS.md
  4+++ b/DOCS.md
  5@@ -463,6 +463,15 @@
  6 @returns {boolean} 
  7 @constructor
  8 ```
  9+
 10+### ISNUMBER 
 11+
 12+```
 13+  Returns true if value or reference is a number. 
 14+@param value - value or reference to check. 
 15+@returns {boolean} 
 16+@constructor
 17+```
 18 ## Logical
 19 
 20 
 21diff --git a/TODO.md b/TODO.md
 22index 3b5ddd0..4a96f22 100644
 23--- a/TODO.md
 24+++ b/TODO.md
 25@@ -33,7 +33,6 @@ For example 64 tbs to a qt.
 26 * ISFORMULA
 27 * ISNA
 28 * ISNONTEXT
 29-* ISNUMBER
 30 * ISREF
 31 * ISURL
 32 * N
 33diff --git a/dist/Formulas/AllFormulas.js b/dist/Formulas/AllFormulas.js
 34index aecda72..c9494b9 100644
 35--- a/dist/Formulas/AllFormulas.js
 36+++ b/dist/Formulas/AllFormulas.js
 37@@ -75,6 +75,7 @@ var Info_1 = require("./Info");
 38 exports.NA = Info_1.NA;
 39 exports.ISTEXT = Info_1.ISTEXT;
 40 exports.ISLOGICAL = Info_1.ISLOGICAL;
 41+exports.ISNUMBER = Info_1.ISNUMBER;
 42 var Lookup_1 = require("./Lookup");
 43 exports.CHOOSE = Lookup_1.CHOOSE;
 44 var Logical_1 = require("./Logical");
 45diff --git a/dist/Formulas/Info.js b/dist/Formulas/Info.js
 46index 7235711..aba3f1f 100644
 47--- a/dist/Formulas/Info.js
 48+++ b/dist/Formulas/Info.js
 49@@ -34,3 +34,14 @@ var ISLOGICAL = function (value) {
 50     return typeof TypeConverter_1.TypeConverter.firstValue(value) === "boolean";
 51 };
 52 exports.ISLOGICAL = ISLOGICAL;
 53+/**
 54+ * Returns true if value or reference is a number.
 55+ * @param value - value or reference to check.
 56+ * @returns {boolean}
 57+ * @constructor
 58+ */
 59+var ISNUMBER = function (value) {
 60+    ArgsChecker_1.ArgsChecker.checkLength(arguments, 1, "ISNUMBER");
 61+    return typeof TypeConverter_1.TypeConverter.firstValue(value) === "number";
 62+};
 63+exports.ISNUMBER = ISNUMBER;
 64diff --git a/src/Formulas/AllFormulas.ts b/src/Formulas/AllFormulas.ts
 65index b3ef233..cf47640 100644
 66--- a/src/Formulas/AllFormulas.ts
 67+++ b/src/Formulas/AllFormulas.ts
 68@@ -73,7 +73,8 @@ import {
 69 import {
 70   NA,
 71   ISTEXT,
 72-  ISLOGICAL
 73+  ISLOGICAL,
 74+  ISNUMBER
 75 } from "./Info";
 76 import {
 77   CHOOSE
 78@@ -331,5 +332,6 @@ export {
 79   STDEVP,
 80   STDEVPA,
 81   ISTEXT,
 82-  ISLOGICAL
 83+  ISLOGICAL,
 84+  ISNUMBER
 85 }
 86\ No newline at end of file
 87diff --git a/src/Formulas/Info.ts b/src/Formulas/Info.ts
 88index 21c9e1c..1ec1248 100644
 89--- a/src/Formulas/Info.ts
 90+++ b/src/Formulas/Info.ts
 91@@ -43,8 +43,21 @@ var ISLOGICAL = function (value) {
 92 };
 93 
 94 
 95+/**
 96+ * Returns true if value or reference is a number.
 97+ * @param value - value or reference to check.
 98+ * @returns {boolean}
 99+ * @constructor
100+ */
101+var ISNUMBER = function (value) {
102+  ArgsChecker.checkLength(arguments, 1, "ISNUMBER");
103+  return typeof TypeConverter.firstValue(value) === "number";
104+};
105+
106+
107 export {
108   NA,
109   ISTEXT,
110-  ISLOGICAL
111+  ISLOGICAL,
112+  ISNUMBER
113 }
114\ No newline at end of file
115diff --git a/tests/Formulas/InfoTest.ts b/tests/Formulas/InfoTest.ts
116index a7d0954..c033175 100644
117--- a/tests/Formulas/InfoTest.ts
118+++ b/tests/Formulas/InfoTest.ts
119@@ -1,7 +1,8 @@
120 import {
121   NA,
122   ISTEXT,
123-  ISLOGICAL
124+  ISLOGICAL,
125+  ISNUMBER
126 } from "../../src/Formulas/Info";
127 import * as ERRORS from "../../src/Errors";
128 import {
129@@ -36,3 +37,13 @@ test("ISLOGICAL", function(){
130     ISLOGICAL.apply(this, []);
131   }, ERRORS.NA_ERROR);
132 });
133+
134+test("ISNUMBER", function(){
135+  assertEquals(ISNUMBER("str"), false);
136+  assertEquals(ISNUMBER(9), true);
137+  assertEquals(ISNUMBER(false), false);
138+  assertEquals(ISNUMBER(true), false);
139+  catchAndAssertEquals(function() {
140+    ISNUMBER.apply(this, []);
141+  }, ERRORS.NA_ERROR);
142+});
143diff --git a/tests/SheetFormulaTest.ts b/tests/SheetFormulaTest.ts
144index 51198ca..611e1aa 100644
145--- a/tests/SheetFormulaTest.ts
146+++ b/tests/SheetFormulaTest.ts
147@@ -663,6 +663,10 @@ test("Sheet ISLOGICAL", function(){
148   assertFormulaEquals('=ISLOGICAL(true)', true);
149 });
150 
151+test("Sheet ISNUMBER", function(){
152+  assertFormulaEquals('=ISNUMBER(5)', true);
153+});
154+
155 test("Sheet *", function(){
156   assertFormulaEquals('= 10 * 10', 100);
157   assertFormulaEquals('= 10 * 0', 0);