f7
f7 is a spreadsheet formula execution library
git clone https://git.vogt.world/f7.git
Log | Files | README.md | LICENSE.md
← All files
name: src/main/js/formulas/logic/GT.ts
-rw-r--r--
1095
 1import { F7Exception } from "../../errors/F7Exception";
 2import { ComparisonResult } from "../../models/common/ComparisonResults";
 3import { SheetColumnRowKey } from "../../models/common/SheetColumnRowKey";
 4import { Complex } from "../../models/common/Types";
 5import { Compare } from "../../utils/Compare";
 6import { Converters } from "../../utils/Converters";
 7import { AbstractFormula } from "../AbstractFormula";
 8import { FormulaName } from "../FormulaName";
 9
10export class GT extends AbstractFormula {
11  static SELF: GT = new GT();
12  NAME = FormulaName.GT;
13
14  internal(origin: SheetColumnRowKey, ...values: Array<Complex>) {
15    AbstractFormula.checkLength(values.length, 2, this.NAME);
16    const first = Converters.first(this.collateralLookup(origin, values[0]));
17    const second = Converters.first(this.collateralLookup(origin, values[1]));
18    if (first instanceof F7Exception) {
19      return first;
20    }
21    if (second instanceof F7Exception) {
22      return second;
23    }
24    const comparison = Compare.compare(first, second);
25    return comparison === ComparisonResult.GREATER_THAN;
26  }
27}