spreadsheet
typeScript/javascript spreadsheet parser, with formulas.
git clone https://git.vogt.world/spreadsheet.git
Log | Files | README.md
← Commit log
commit
message
[README.md] cleaning up TODOs and outlining type plan
author
Ben Vogt <[email protected]>
date
2017-05-04 03:47:33
stats
2 file(s) changed, 33 insertions(+), 31 deletions(-)
files
README.md
src/Formulas/Financial.ts
  1diff --git a/README.md b/README.md
  2index 82e43fd..cf4338d 100644
  3--- a/README.md
  4+++ b/README.md
  5@@ -4,48 +4,60 @@ TypeScript/javascript implementation of a spreadsheet.
  6 ## TODO
  7 Things I should do.
  8 
  9-### SUM and SUMA should be different, and I'm pretty sure they're currently the same.
 10-And the same for MAX, MAXA, COUNT, COUNTA, etc. Look these over.
 11+
 12+### SUM and SUMA should be different.
 13+
 14+
 15+### MAX and MAXA should be different.
 16+
 17+
 18+### COUNT and COUNTA should be different.
 19+
 20+
 21+### All formulas should used TypeCaster to pull parameters from `values`
 22+
 23 
 24 ### Criteria evaluations should escape reg-ex characters
 25 http://stackoverflow.com/questions/3446170/escape-string-for-use-in-javascript-regex
 26 
 27+
 28 ### functions that throw errors should usually be able to include their caller in the error
 29 e.g. "SUM expects number values...", or "This function expects number values..."
 30 
 31-### Dollar functions have special types
 32-Although dollar functions look like they just format `number`s, it seems like they have a special type under the hood.
 33-This means that we should do dollar->number casting in all casting functions. For now, just using number primitive.
 34-See `DOLLAR` function for more info.
 35 
 36 ### Error formatting
 37 Pass name of calling formula into all functions that throw user-facing errors, or have some sort of error mapper.
 38 
 39-### Dates have special types
 40-* Like dollars, dates are special types, but can be compared as if they're primitives. For example, this statement is
 41-valid inside a cell: `=DATE(1992, 6, 6) > =DATE(1992, 6, 10)`. We should check types and and have Date-to-number
 42-conversion inside parser.js.
 43-* The same rule applies for time-types. It seems like under the hood, times are represented using a number between
 44-0 and 1, exclusive on the end. When comparing them, this: `=TIME(12, 0, 0) = 0.5` evaluates to TRUE, and
 45-`=TIME(12, 0, 0) <> 0.5` evaluates to FALSE.
 46-* Furthermore, it appears that Cells themselves have types. If a cell contains `=TIME(12, 0, 0) + 0.1`, the result will
 47-not be displayed as a decimal, but instead as a time, eg: "1:12:00 AM". However, you can force the application to display it as
 48-a different type.
 49-* The automatic display type for a Cell seems to be inherited from it's most complex type: [ExcelDate, ExcelTime,
 50-number, boolean, string].
 51+
 52+### Cells should have `formatAs` fields.
 53+Instead of having non-primitives, (i.e. ExcelDate, ExcelTime, Dollar), cells should have formats based on the
 54+highest-order type that was used during the compilation and execution of a cell's dependency. For example, `DATE` might
 55+return a number, but the cell that called `DATE` would be aware of it calling a formula that returns an non-primative
 56+type, and would display the returned number as a Date. If you're using `DATE` in conjunction with `DOLLAR` it would
 57+still display the returned value as a Date. The heirarhchy would look like: [ExcelDate, ExcelTime, Dollar, number,
 58+boolean, string]. Advantages to this would include not having to cast down when using primitive operators,
 59+and flexibility in display. It would also simplify the types themselves, by having types be constants and just having
 60+helpers to convert, display, and do normal operations with them.
 61+
 62 
 63 ### Test all ExcelDate functions
 64 Right now we're just using the number of days since 1900, but we should check the other functions.
 65 
 66+
 67 ### Verify that all N-times ({2,9}) are correct, and we're not parsing numbers too big.
 68 
 69+
 70 ### Scrape jsdocs for functions, put in simple index.html, doc.md files to serve up simple documentation
 71 
 72+
 73 ### Numbers with commas in them should still parse to numbers.
 74 
 75+
 76 ### Ensure all formulas are tested inside of SheetFormulaTest.ts
 77 
 78+
 79 ### Test all functions in src/Utilities
 80 
 81+
 82 ### Sheet.ts and parser.js should be able to concatenate strings
 83 E.g. `=COUNTIFS(A7:A24, ">6", B7:B24, "<"&DATE(1969,7,20))`
 84\ No newline at end of file
 85diff --git a/src/Formulas/Financial.ts b/src/Formulas/Financial.ts
 86index 1affc70..151fad5 100644
 87--- a/src/Formulas/Financial.ts
 88+++ b/src/Formulas/Financial.ts
 89@@ -138,14 +138,6 @@ var DB = function (...values) : number {
 90  * @param values[1] places - [ OPTIONAL - 2 by default ] - The number of decimal places to display.
 91  * @returns {number} dollars
 92  * @constructor
 93- * TODO: In GS and Excel, Dollar values are primitive types at a certain level, meaning you can do =DOLLAR(10) + 10
 94- * TODO(cont.) and the result will be 20. Right now, JS allows you to inherit from primitives so you can use operators
 95- * TODO(cont.) on them (eg: new Number(10) + 10 == 20) but TS does not. So for now, Dollar values will be represented
 96- * TODO(cont.) with the primitive number type. At some point TS might allow me to suppress the warnings with
 97- * TODO(cont.) https://github.com/Microsoft/TypeScript/issues/9448 or
 98- * TODO(cont.) https://github.com/Microsoft/TypeScript/issues/11051
 99- *
100- * TODO: Also, this does not do local-specific, as is.
101  */
102 var DOLLAR = function (...values) : number {
103   ArgsChecker.checkLengthWithin(values, 1, 2);