mirror of
https://github.com/Psychotoxical/psysonic.git
synced 2026-07-22 07:15:47 +00:00
d24514d67e
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.
13 lines
590 B
TypeScript
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;
|
|
}
|