Skip to content

Type Alias: DeepEqualComparator

DeepEqualComparator = (a, b) => boolean | undefined

Structural deep-equality with an optional custom comparator.

deepEqual mirrors the semantics of the fast-deep-equal package (handled: nested plain objects/arrays, Map, Set, Date, RegExp, typed arrays, NaN, and +0/-0 treated as equal) but is dependency-free so @dbx-tools/shared-core keeps no runtime deps.

The optional comparator short-circuits the structural walk at any node: return true/false to force the result for that pair, or undefined to defer to the built-in comparison. It is invoked for the root pair and recursively for each nested pair, so a caller can, e.g., compare two domain objects by id while letting everything else fall back to structural equality.

unknown

unknown

boolean | undefined

deepEqual({ a: 1 }, { a: 1 }); // true
deepEqual([1, 2], [1, 2]); // true
deepEqual(a, b, (x, y) =>
isEntity(x) && isEntity(y) ? x.id === y.id : undefined);