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/math/PRODUCT.ts
-rw-r--r--
878
 1import { isNotNull } from "../../utils/Other";
 2import { SheetColumnRowKey } from "../../models/common/SheetColumnRowKey";
 3import { Complex } from "../../models/common/Types";
 4import { Converters } from "../../utils/Converters";
 5import { Mappers } from "../../utils/Mappers";
 6import { Reducers } from "../../utils/Reducers";
 7import { AbstractFormula } from "../AbstractFormula";
 8import { FormulaName } from "../FormulaName";
 9
10export class PRODUCT extends AbstractFormula {
11  static SELF: PRODUCT = new PRODUCT();
12  NAME = FormulaName.SUM;
13
14  internal(origin: SheetColumnRowKey, ...values: Array<Complex>) {
15    AbstractFormula.checkAtLeastLength(values.length, 1, this.NAME);
16    return values
17      .map(this.lookup)
18      .map(Mappers.toFlatStream)
19      .reduce(Reducers.join)
20      .filter(isNotNull)
21      .map(Converters.toNumber)
22      .reduce(Reducers.product, 1);
23  }
24}