• One-level structural equality predicate.

    Type Parameters

    • T

      The compared value type.

    Parameters

    • a: T

      First value to compare.

    • b: T

      Second value to compare.

    Returns boolean

    true when the values are Object.is-equal, or are arrays of equal length whose indices are pairwise Object.is-equal, or are plain objects with the same own-key set whose values are pairwise Object.is-equal; otherwise false.

    The predicate is intentionally one level deep — nested objects are compared by reference. That matches the dedup contract: callers who need deeper structural equality should pre-normalise inside the selector or memoise the deeper structures elsewhere.

    shallowEqual({ a: 1, b: 2 }, { a: 1, b: 2 }) // true
    shallowEqual([1, 2, 3], [1, 2, 3]) // true
    shallowEqual({ a: { x: 1 } }, { a: { x: 1 } }) // false (nested ref differs)