@@ -6,7 +6,6 @@ import { Point } from "./point";
66import * as pointGraph from "./point-graph" ;
77import * as pointSet from "./point-set" ;
88import { CellBase } from "./types" ;
9- import { isFormulaCell } from "./util" ;
109
1110export class Model < Cell extends CellBase > {
1211 readonly data ! : matrix . Matrix < Cell > ;
@@ -32,7 +31,7 @@ export function updateCellValue<Cell extends CellBase>(
3231 cell : Cell
3332) : Model < Cell > {
3433 const nextData = matrix . set ( point , cell , model . data ) ;
35- const nextReferenceGraph = isFormulaCell ( cell )
34+ const nextReferenceGraph = Formula . isFormulaValue ( cell . value )
3635 ? updateReferenceGraph ( model . referenceGraph , point , cell , nextData )
3736 : model . referenceGraph ;
3837
@@ -102,8 +101,8 @@ function evaluateCell<Cell extends CellBase>(
102101 ( ) => nextEvaluatedData
103102 ) ;
104103
105- const evaluatedValue = isFormulaCell ( cell )
106- ? getFormulaComputedValue ( cell , point , formulaParser )
104+ const evaluatedValue = Formula . isFormulaValue ( cell . value )
105+ ? getFormulaComputedValue ( cell . value , point , formulaParser )
107106 : cell . value ;
108107
109108 const evaluatedCell = { ...cell , value : evaluatedValue } ;
@@ -119,8 +118,8 @@ function evaluateCell<Cell extends CellBase>(
119118 if ( ! referrerCell ) {
120119 continue ;
121120 }
122- const evaluatedValue = isFormulaCell ( referrerCell )
123- ? getFormulaComputedValue ( referrerCell , point , formulaParser )
121+ const evaluatedValue = Formula . isFormulaValue ( referrerCell . value )
122+ ? getFormulaComputedValue ( referrerCell . value , point , formulaParser )
124123 : referrerCell . value ;
125124 const evaluatedCell = { ...referrerCell , value : evaluatedValue } ;
126125 nextEvaluatedData = matrix . set ( referrer , evaluatedCell , nextEvaluatedData ) ;
@@ -139,7 +138,7 @@ export function createReferenceGraph(
139138) : pointGraph . PointGraph {
140139 const entries : Array < [ Point , pointSet . PointSet ] > = [ ] ;
141140 for ( const [ point , cell ] of matrix . entries ( data ) ) {
142- if ( cell && isFormulaCell ( cell ) ) {
141+ if ( cell && Formula . isFormulaValue ( cell . value ) ) {
143142 const references = getReferences (
144143 Formula . extractFormula ( cell . value ) ,
145144 point ,
@@ -168,9 +167,9 @@ export function createEvaluatedData<Cell extends CellBase>(
168167 }
169168
170169 // If the cell is a formula cell, evaluate it
171- if ( isFormulaCell ( cell ) ) {
170+ if ( Formula . isFormulaValue ( cell . value ) ) {
172171 const evaluatedValue = getFormulaComputedValue (
173- cell ,
172+ cell . value ,
174173 point ,
175174 formulaParser
176175 ) ;
@@ -187,10 +186,10 @@ export function createEvaluatedData<Cell extends CellBase>(
187186
188187/** Get the computed value of a formula cell */
189188export function getFormulaComputedValue (
190- cell : CellBase < string > ,
189+ value : string ,
191190 point : Point ,
192191 formulaParser : FormulaParser
193192) : Value {
194- const formula = Formula . extractFormula ( cell . value ) ;
193+ const formula = Formula . extractFormula ( value ) ;
195194 return Formula . evaluate ( formula , point , formulaParser ) ;
196195}
0 commit comments