import { Utilities } from "point-utilities"; import { GetPointForValue } from "../../types"; export function sliceValues( sortedValues: Value[], start: Point, end: Point, getPointForValue: GetPointForValue, pointUtils: Utilities ): Value[] { if (sortedValues.length === 0) { return []; } const sortedPoints = sortedValues.map(getPointForValue); const startIndex = pointUtils.findNearestIndexAfter(sortedPoints, start); const endIndex = pointUtils.findNearestIndexBefore(sortedPoints, end); return sortedValues.slice(startIndex, endIndex + 1); }