import { Platform } from 'react-native'; export const isAndroid = Platform.OS === 'android'; export function pick( keys: T[], obj: O ): Pick { return keys .filter((key) => key in obj) .reduce>( (result, cur) => ({ ...result, [cur]: obj[cur], }), {} ) as Pick; } export function omit(keys: T[], obj: O): Omit { const result = { ...obj }; keys.forEach((key) => { delete result[key]; }); return result; } export const deepCompareValue = (a: V, b: V): boolean => { // Handle strict equality first (handles primitives, null, undefined) if (a === b) return true; // Special handling for NaN (NaN !== NaN in JS) if ( typeof a === 'number' && typeof b === 'number' && Number.isNaN(a) && Number.isNaN(b) ) { return false; } // If either is null or undefined (but they are not strictly equal), return false if (a == null || b == null) return false; // If types don't match, they can't be equal if (typeof a !== typeof b) return false; // Handle array comparison if (Array.isArray(a) && Array.isArray(b)) { if (a.length !== b.length) return false; return a.every((val, index) => deepCompareValue(val, b[index])); } // If one is array and the other isn't, return false if (Array.isArray(a) !== Array.isArray(b)) return false; // Handle object comparison if (typeof a === 'object' && typeof b === 'object') { const keysA = Object.keys(a) as (keyof V)[]; const keysB = Object.keys(b) as (keyof V)[]; if (keysA.length !== keysB.length) return false; return keysA.every( (key) => keysB.includes(key) && deepCompareValue(a[key], b[key]) ); } // If none of the above conditions matched, they're not equal return false; };