@rowsncolumns/fast-formula-parser 6.2.34 → 6.2.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/esm/index.js CHANGED
@@ -45528,6 +45528,17 @@ class DepParser {
45528
45528
  if (fnName === "OFFSET") {
45529
45529
  return this.handleOffset(args);
45530
45530
  }
45531
+ // ADDRESS is pure and is the idiomatic way to build INDIRECT's
45532
+ // target. Folding it here lets handleIndirect register the real
45533
+ // precedent edge (`INDIRECT(ADDRESS(1,3,1,1,"Source"))` →
45534
+ // Source!$C$1), so the calc engine orders the INDIRECT cell after
45535
+ // the chain it reads instead of evaluating it against stale values.
45536
+ if (fnName === "ADDRESS") {
45537
+ const folded = this.foldAddress(args);
45538
+ if (folded !== undefined) {
45539
+ return { value: folded };
45540
+ }
45541
+ }
45531
45542
  // Phase 7 LAMBDA: __RNC_LAMBDA__("params", "body") is the
45532
45543
  // preprocessor's runtime lambda constructor. The body is a string
45533
45544
  // literal that may contain cell refs — recurse the dep parser on
@@ -45594,6 +45605,31 @@ class DepParser {
45594
45605
  }
45595
45606
  }
45596
45607
 
45608
+ /**
45609
+ * Evaluate ADDRESS(...) when every argument is a literal scalar.
45610
+ * Returns undefined when an argument is a reference or another
45611
+ * function's placeholder result (the dep parser does not evaluate
45612
+ * those), or when ADDRESS itself would error.
45613
+ */
45614
+ foldAddress(args = []) {
45615
+ if (!args.length || args.length > 5) return undefined;
45616
+ const scalars = [];
45617
+ for (const arg of args) {
45618
+ if (arg == null) {
45619
+ scalars.push(undefined);
45620
+ continue;
45621
+ }
45622
+ if (typeof arg === "object") return undefined;
45623
+ scalars.push(arg);
45624
+ }
45625
+ try {
45626
+ const address = ReferenceFunctions.ADDRESS(...scalars);
45627
+ return typeof address === "string" ? address : undefined;
45628
+ } catch {
45629
+ return undefined;
45630
+ }
45631
+ }
45632
+
45597
45633
  handleIndirect(args = []) {
45598
45634
  const refText = this.extractScalar(args[0]);
45599
45635
  if (typeof refText !== "string") {