Files
Psychotoxical-psysonic/src/utils/normalizationCompare.ts
T
Frank Stellmacher d24514d67e refactor(player): E.3 — extract waveform/normalization/seek pure helpers (#566)
Three small tranches out of playerStore.ts:
- src/utils/waveformParse.ts — waveformBlobLenOk + coerceWaveformBins (the
  parser that handles number[] / Uint8Array / ArrayLike payloads Rust
  serializes as).
- src/utils/normalizationCompare.ts — normalizationAlmostEqual (tolerant
  null-aware dB comparison).
- src/utils/seekErrors.ts — isRecoverableSeekError (retry classifier for
  the Rust seek pipeline).

Each gets focused unit tests. All four were file-private, no external
callers — pure code move. playerStore 3556 → 3516 LOC.
2026-05-12 11:45:09 +02:00

13 lines
590 B
TypeScript

/**
* Tolerant equality for normalization gain values. Both arguments may be null
* (meaning "no override / unknown"); two nulls compare equal, mixed null/number
* does not. Default epsilon (0.12 dB) is the threshold below which the audible
* difference is negligible — used to skip UI updates that would otherwise jitter
* on every analysis-cache refresh.
*/
export function normalizationAlmostEqual(a: number | null, b: number | null, eps = 0.12): boolean {
if (a == null && b == null) return true;
if (a == null || b == null) return false;
return Math.abs(a - b) <= eps;
}