import { DeepPath, DeepPathValue } from "../__utils/types"; export function unstable_getIn< T extends Record, P extends DeepPath, D >(object: T, path: P, defaultValue: D): D; export function unstable_getIn< T extends Record, P extends DeepPath >(object: T, path: P, defaultValue?: any): DeepPathValue | undefined; export function unstable_getIn( object: Record, path: string | any[], defaultValue?: any ) { if (typeof path === "string") { return object[path] == null ? defaultValue : object[path]; } let result = object; for (const key of path) { if (!(key in result)) return defaultValue; result = result[key]; } if (result == null) { return defaultValue; } return result; }