applies formatting and linting

This commit is contained in:
2025-01-01 15:51:19 -05:00
parent 825b85ddad
commit 59431ebfff
13 changed files with 325 additions and 179 deletions

View File

@@ -38,18 +38,27 @@ export class PointLine {
const index = this.find_index(point.x);
this.data.splice(index, 0, point);
if (maximum_separation !== undefined) {
this.reduce_to_maximum_separation(maximum_separation, [index - 1, index + 1]);
this.reduce_to_maximum_separation(maximum_separation, [
index - 1,
index + 1,
]);
}
}
reduce_to_maximum_separation(maximum_separation: number, range?: [number, number]) {
reduce_to_maximum_separation(
maximum_separation: number,
range?: [number, number],
) {
if (maximum_separation <= 0) {
return;
}
// Add a default range if it does not exist
range = range || [1, this.data.length - 2];
// clamp it to the bounds
range = [Math.max(1, range[0]), Math.min(this.data.length - 2, range[1])];
range = [
Math.max(1, range[0]),
Math.min(this.data.length - 2, range[1]),
];
// Loop over the indices in the range (backwards so removals don't break anything)
for (let i = range[1]; i >= range[0]; i--) {
@@ -61,7 +70,10 @@ export class PointLine {
const separation_after = x_next - x_current;
// If the data points are too close on both sides then delete this point
if (separation_before < maximum_separation && separation_after < maximum_separation) {
if (
separation_before < maximum_separation &&
separation_after < maximum_separation
) {
this.data.splice(i, 1);
}
}