UNPKG

hyperformula

Version:

HyperFormula is a JavaScript engine for efficient processing of spreadsheet-like data and formulas

41 lines (36 loc) 1.34 kB
import "core-js/modules/es.array.from.js"; import "core-js/modules/es.string.iterator.js"; import "core-js/modules/es.array.filter.js"; import "core-js/modules/es.array.map.js"; /** * @license * Copyright (c) 2021 Handsoncode. All rights reserved. */ import { AddressDependency, collectDependencies } from '../parser'; import { FormulaVertex } from './FormulaCellVertex'; import { RangeVertex } from './RangeVertex'; export var collectAddressesDependentToRange = function collectAddressesDependentToRange(funcitonRegistry, vertex, range, lazilyTransformingAstService, dependencyGraph) { if (vertex instanceof RangeVertex) { var intersection = vertex.range.intersectionWith(range); if (intersection !== undefined) { return Array.from(intersection.addresses(dependencyGraph)); } else { return []; } } var formula; var address; if (vertex instanceof FormulaVertex) { formula = vertex.getFormula(lazilyTransformingAstService); address = vertex.getAddress(lazilyTransformingAstService); } else { return []; } return collectDependencies(formula, funcitonRegistry).filter(function (d) { return d instanceof AddressDependency; }).map(function (d) { return d.dependency.toSimpleCellAddress(address); }).filter(function (d) { return range.addressInRange(d); }); };