spreadsheet
typeScript/javascript spreadsheet parser, with formulas.
git clone https://git.vogt.world/spreadsheet.git
Log | Files | README.md
← Commit log
commit
message
[ISTEXT] formula added and tested
author
Ben Vogt <[email protected]>
date
2017-06-16 00:11:25
stats
8 file(s) changed, 57 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 f6b9595..b68baeb 100644
  3--- a/DOCS.md
  4+++ b/DOCS.md
  5@@ -445,6 +445,15 @@
  6   Returns the "value not available" error, "#NA". 
  7 @constructor
  8 ```
  9+
 10+### ISTEXT 
 11+
 12+```
 13+  Returns true if a value is text. 
 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 dd6c06e..e4cc06e 100644
 23--- a/TODO.md
 24+++ b/TODO.md
 25@@ -36,7 +36,6 @@ For example 64 tbs to a qt.
 26 * ISNONTEXT
 27 * ISNUMBER
 28 * ISREF
 29-* ISTEXT
 30 * ISURL
 31 * N
 32 * TYPE
 33diff --git a/dist/Formulas/AllFormulas.js b/dist/Formulas/AllFormulas.js
 34index 3244e7e..c5cd84a 100644
 35--- a/dist/Formulas/AllFormulas.js
 36+++ b/dist/Formulas/AllFormulas.js
 37@@ -73,6 +73,7 @@ exports.UPLUS = Math_1.UPLUS;
 38 exports.UMINUS = Math_1.UMINUS;
 39 var Info_1 = require("./Info");
 40 exports.NA = Info_1.NA;
 41+exports.ISTEXT = Info_1.ISTEXT;
 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 a2ff652..18152ae 100644
 47--- a/dist/Formulas/Info.js
 48+++ b/dist/Formulas/Info.js
 49@@ -11,3 +11,14 @@ var NA = function () {
 50     throw new Errors_1.NAError("NA Error thrown.");
 51 };
 52 exports.NA = NA;
 53+/**
 54+ * Returns true if a value is text.
 55+ * @param value - value or reference to check.
 56+ * @returns {boolean}.
 57+ * @constructor
 58+ */
 59+var ISTEXT = function (value) {
 60+    ArgsChecker_1.ArgsChecker.checkLength(arguments, 1, "ISTEXT");
 61+    return typeof value === "string";
 62+};
 63+exports.ISTEXT = ISTEXT;
 64diff --git a/src/Formulas/AllFormulas.ts b/src/Formulas/AllFormulas.ts
 65index 4e4b67d..290d75e 100644
 66--- a/src/Formulas/AllFormulas.ts
 67+++ b/src/Formulas/AllFormulas.ts
 68@@ -71,7 +71,8 @@ import {
 69   UMINUS
 70 } from "./Math";
 71 import {
 72-  NA
 73+  NA,
 74+  ISTEXT
 75 } from "./Info";
 76 import {
 77   CHOOSE
 78@@ -327,5 +328,6 @@ export {
 79   STDEV,
 80   STDEVA,
 81   STDEVP,
 82-  STDEVPA
 83+  STDEVPA,
 84+  ISTEXT
 85 }
 86\ No newline at end of file
 87diff --git a/src/Formulas/Info.ts b/src/Formulas/Info.ts
 88index 3ea5bbc..2f3b5b9 100644
 89--- a/src/Formulas/Info.ts
 90+++ b/src/Formulas/Info.ts
 91@@ -16,6 +16,19 @@ var NA = function () {
 92 };
 93 
 94 
 95+/**
 96+ * Returns true if a value is text.
 97+ * @param value - value or reference to check.
 98+ * @returns {boolean}.
 99+ * @constructor
100+ */
101+var ISTEXT =  function (value) {
102+  ArgsChecker.checkLength(arguments, 1, "ISTEXT");
103+  return typeof value === "string";
104+};
105+
106+
107 export {
108-  NA
109+  NA,
110+  ISTEXT
111 }
112\ No newline at end of file
113diff --git a/tests/Formulas/InfoTest.ts b/tests/Formulas/InfoTest.ts
114index 32bd4a0..dfa8d6c 100644
115--- a/tests/Formulas/InfoTest.ts
116+++ b/tests/Formulas/InfoTest.ts
117@@ -1,8 +1,10 @@
118 import {
119-  NA
120+  NA,
121+  ISTEXT
122 } from "../../src/Formulas/Info";
123 import * as ERRORS from "../../src/Errors";
124 import {
125+  assertEquals,
126   catchAndAssertEquals,
127   test
128 } from "../Utils/Asserts";
129@@ -13,3 +15,12 @@ test("NA", function(){
130     NA();
131   }, ERRORS.NA_ERROR);
132 });
133+
134+test("ISTEXT", function(){
135+  assertEquals(ISTEXT("str"), true);
136+  assertEquals(ISTEXT(9), false);
137+  assertEquals(ISTEXT(false), false);
138+  catchAndAssertEquals(function() {
139+    ISTEXT.apply(this, []);
140+  }, ERRORS.NA_ERROR);
141+});
142diff --git a/tests/SheetFormulaTest.ts b/tests/SheetFormulaTest.ts
143index 26efd6f..c49c767 100644
144--- a/tests/SheetFormulaTest.ts
145+++ b/tests/SheetFormulaTest.ts
146@@ -655,6 +655,10 @@ test("Sheet NA", function(){
147   assertFormulaEqualsError('=NA()', NA_ERROR);
148 });
149 
150+test("Sheet ISTEXT", function(){
151+  assertFormulaEquals('=ISTEXT("str")', true);
152+});
153+
154 test("Sheet *", function(){
155   assertFormulaEquals('= 10 * 10', 100);
156   assertFormulaEquals('= 10 * 0', 0);