export const isNil = (value: unknown): value is null | undefined => value === null || value === undefined; export const castTo = (value: unknown): NewType => value as NewType; export const hasOwnProperty = ( obj: X, property: Y // eslint-disable-next-line no-prototype-builtins ): obj is X & Record => obj.hasOwnProperty(property); export const deepClone = (obj: T): T => { if (typeof obj !== 'object' || obj === null) return obj as T; const clone = Array.isArray(obj) ? castTo([]) : ({} as T); for (const key in obj) { const value = obj[key]; clone[key] = deepClone(value); } return clone as T; }; export const omit = (obj: T, keys: K[]): Omit => { const clone = deepClone(obj); for (const key of keys) { delete clone[key]; } return clone; }; export const pick = (obj: T, keys: K[]): Pick => { const clone = Array.isArray(obj) ? castTo([]) : ({} as T); for (const key of keys) { clone[key] = obj[key]; } return clone; };