Fix orphaned debug log and array bounds check

- Remove console.log('hello:') from Measurement.js (#22)
- Add bounds check for peakIndex in predict_class.js (#23)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Rene De Ren
2026-03-11 14:56:42 +01:00
parent c698e5a1bc
commit 96fdf2a27a

View File

@@ -161,6 +161,11 @@ class Predict {
//find index of y peak
const { peak , peakIndex } = this.getLocalPeak(curve.y);
// Guard against invalid peakIndex (e.g. empty array returns -1)
if (peakIndex < 0 || peakIndex >= curve.x.length) {
return { yPeak: null, x: null, xProcent: null };
}
// scale the x value to procentual value
const yPeak = peak;
const x = curve.x[peakIndex];