/** * Returns `true` when every adjacent pair in `values` is at least * `step * minStepsBetweenValues` apart. For a scalar input the invariant is * vacuous — a single thumb has no neighbour to collide with — so the * function short-circuits to `true`. */ export function validateMinimumDistance( values: number | readonly number[], step: number, minStepsBetweenValues: number, ): boolean { if (!Array.isArray(values)) { return true; } const distances = values.reduce((acc: number[], val, index, vals) => { if (index === vals.length - 1) { return acc; } // biome-ignore lint/style/noNonNullAssertion: index+1 < length here acc.push(Math.abs(val - vals[index + 1]!)); return acc; }, []); return Math.min(...distances) >= step * minStepsBetweenValues; }