Compare two arrays for exact equality (or within epsilon when set).
epsilon = 0 (default) does true equality on each element via Math.abs.
Pass a positive epsilon for tolerance-based comparison.
NaN/Inf semantics (load-bearing for WASM-vs-TS parity): a naive
Math.abs(a - b) > epsilon check is NaN-BLIND — when either side is NaN the
subtraction is NaN and NaN > epsilon is false, so a backend that emits NaN
while the other emits a finite value would be reported EQUAL, silently hiding a
real divergence. We therefore:
treat NaN-vs-finite (exactly one side NaN) as a MISMATCH,
treat NaN-vs-NaN as equal,
let the existing magnitude check handle ±Inf correctly: same-sign Inf
yields Inf - Inf = NaN (not > epsilon) → equal, while +Inf vs -Inf
or Inf vs finite yields Inf > epsilon → mismatch.
Compare two arrays for exact equality (or within epsilon when set).
epsilon = 0(default) does true equality on each element viaMath.abs. Pass a positive epsilon for tolerance-based comparison.NaN/Inf semantics (load-bearing for WASM-vs-TS parity): a naive
Math.abs(a - b) > epsiloncheck is NaN-BLIND — when either side is NaN the subtraction is NaN andNaN > epsilonisfalse, so a backend that emits NaN while the other emits a finite value would be reported EQUAL, silently hiding a real divergence. We therefore:Inf - Inf = NaN(not> epsilon) → equal, while+Infvs-Infor Inf vs finite yieldsInf > epsilon→ mismatch.