spreadsheet
typeScript/javascript spreadsheet parser, with formulas.
git clone https://git.vogt.world/spreadsheet.git
Log | Files | README.md
← Commit log
commit
message
Docs and cleaning up Sheet.ts
author
Ben Vogt <[email protected]>
date
2017-05-17 03:43:21
stats
3 file(s) changed, 7 insertions(+), 21 deletions(-)
files
README.md
src/Sheet.ts
src/Utilities/CriteriaFunctionFactory.ts
 1diff --git a/README.md b/README.md
 2index 618c91f..4a7a42f 100644
 3--- a/README.md
 4+++ b/README.md
 5@@ -17,10 +17,6 @@ Things I should do.
 6 ### All formulas should used TypeConverter to pull parameters from `values`
 7 
 8 
 9-### Criteria evaluations should escape reg-ex characters
10-http://stackoverflow.com/questions/3446170/escape-string-for-use-in-javascript-regex
11-
12-
13 ### Cells should have `formatAs` fields.
14 Instead of having non-primitives, (i.e. Date, DateTime, Time, Dollar), cells should have formats based on the
15 highest-order type that was used during the compilation and execution of a cell's dependency. For example, `DATE` might
16diff --git a/src/Sheet.ts b/src/Sheet.ts
17index 7acff7c..71780af 100644
18--- a/src/Sheet.ts
19+++ b/src/Sheet.ts
20@@ -195,27 +195,15 @@ var Sheet = (function () {
21 
22   var utils = {
23     isArray: function (value) {
24-      return Object.prototype.toString.call(value) === '[object Array]';
25-    },
26-
27-    isNumber: function (value) {
28-      return Object.prototype.toString.call(value) === '[object Number]';
29-    },
30-
31-    isString: function (value) {
32-      return Object.prototype.toString.call(value) === '[object String]';
33+      return value instanceof Array;
34     },
35 
36     isFunction: function (value) {
37-      return Object.prototype.toString.call(value) === '[object Function]';
38-    },
39-
40-    isUndefined: function (value) {
41-      return Object.prototype.toString.call(value) === '[object Undefined]';
42+      return value instanceof Function;
43     },
44 
45     isNull: function (value) {
46-      return Object.prototype.toString.call(value) === '[object Null]';
47+      return value === null;
48     },
49 
50     isSet: function (value) {
51@@ -450,7 +438,7 @@ var Sheet = (function () {
52       if (str) {
53         str = str.toUpperCase();
54         if (Formulas.exists(str)) {
55-          return ((typeof Formulas.get(str) === 'function') ? Formulas.get(str).apply(this, args) : Formulas.get(str));
56+          return Formulas.get(str).apply(this, args);
57         }
58       }
59 
60diff --git a/src/Utilities/CriteriaFunctionFactory.ts b/src/Utilities/CriteriaFunctionFactory.ts
61index bee94e3..7b094b6 100644
62--- a/src/Utilities/CriteriaFunctionFactory.ts
63+++ b/src/Utilities/CriteriaFunctionFactory.ts
64@@ -1,6 +1,8 @@
65 /**
66  * Converts wild-card style expressions (in which * matches zero or more characters, and ? matches exactly one character)
67- * to regular expressions. * and ? can be escaped by prefixing ~
68+ * to regular expressions. * and ? can be escaped by prefixing with ~.
69+ * For future reference, something like this might be better
70+ * http://stackoverflow.com/questions/3446170/escape-string-for-use-in-javascript-regex.
71  * @param c input
72  * @returns {RegExp} resulting regex
73  */