UNPKG

tracked-instance

Version:
22 lines (21 loc) 1.1 kB
/** * Recursively makes all properties of T optional. * Arrays use element-level DeepPartial rather than making the array itself optional, * which allows sparse array diffs (e.g. only index 2 changed). */ export type DeepPartial<Value> = Value extends object ? Value extends Array<infer ArrayValue> ? Array<DeepPartial<ArrayValue>> : { [Property in keyof Value]?: DeepPartial<Value[Property]>; } : Value; /** * Returns true only for plain objects — intentionally excludes Array, Date, File, Map, * and Set so they are treated as atomic leaf values rather than being traversed. */ export declare const isObject: (value: unknown) => value is Record<string, any>; /** * Deep-clones a value while preserving special types: * - Date → new Date instance with the same timestamp * - File → same reference (Files are immutable browser objects and cannot be meaningfully cloned) * - Map / Set / other class instances → same reference (treated as atomic by isObject) * Plain objects and arrays are recursively cloned. */ export declare const cloneDeep: <Value>(value: Value) => Value;