/** * Shallow equality check for selector results. * Uses Object.is for value comparison (handles NaN and +-0 correctly). */ export function shallowEqual(a: T, b: T): boolean { if (Object.is(a, b)) return true; if ( typeof a !== "object" || a === null || typeof b !== "object" || b === null ) { return false; } const keysA = Object.keys(a); const keysB = Object.keys(b); if (keysA.length !== keysB.length) return false; for (const key of keysA) { if ( !Object.hasOwn(b, key) || !Object.is((a as any)[key], (b as any)[key]) ) { return false; } } return true; }