type Flatten = T extends Array ? Flatten[] : T extends object ? { [K in keyof T as K extends string ? `${K}` : never]: T[K] extends object ? T[K] extends Date | RegExp | File | Blob ? T[K] : Flatten : T[K]; } : T; /** * Recursively flattens a nested object into a flat object with dot-separated keys. * * This function takes an object, potentially containing nested objects and arrays, * and returns a new object where all nested objects are flattened into dot-separated * key-value pairs. Arrays are flattened with index-based keys. * * @template T - The type of the input object. * @param {T} obj - The object to be flattened. * @param {string} [prefix=""] - An optional prefix to prepend to each key in the flattened object. * @returns {Flatten} - A flattened version of the input object. * * @example * const input = { a: { b: 1, c: [2, 3] } }; * const result = flattenObject(input); * // result: { 'a.b': 1, 'a.c.0': 2, 'a.c.1': 3 } */ export declare function flattenObject(obj: T, prefix?: string): Flatten; type DotToNested = T extends Record ? { [K in keyof T as K extends `${infer P}.${infer R}` ? P : K]: K extends `${infer P}.${infer R}` ? DotToNested<{ [key in R]: T[K]; }> : T[K]; } : never; type Merge = (T extends any ? (x: T) => void : never) extends (x: infer R) => void ? { [K in keyof R]: R[K]; } : never; type MergeUnion = Merge; type Atomic = Date | RegExp | File | Blob; type DeepMerge = { [K in keyof T]: T[K] extends Atomic ? T[K] : T[K] extends object ? Merge> : T[K]; }; type NumericKeys = Extract; type IsNumericObject = keyof T extends NumericKeys ? true : false; type ObjectToArray = T extends Atomic ? T : IsNumericObject extends true ? T extends Record ? U[] : never : { [K in keyof T]: T[K] extends object ? ObjectToArray : T[K]; }; type UnflattenDotNotation = ObjectToArray>>>; /** * Converts a flat object with dot notation keys into a nested object. * * @template T The type of the input object. * @param {T} obj - The object with dot notation keys to be unflattened. * @returns {UnflattenDotNotation} A nested object reconstructed from the dot notation keys. * @throws {Error} If the input is not a valid object or if the structure is invalid. */ export declare function unflattenDotNotation>(obj: T | null | undefined): UnflattenDotNotation; type PickFromObjectParams, K extends keyof T> = { obj: T | undefined; keys: K[]; }; /** * Creates a new object containing only the specified keys from the original object. * * @template T The type of the object from which keys will be picked. * @template K The type of the keys to pick from the object. * * @param {PickFromObjectParams} params - An object containing the original object and the keys to pick. * @param {T | undefined} params.obj - The original object from which keys will be picked. * @param {K[]} params.keys - An array of keys to pick from the object. * @returns {Pick} A new object containing only the picked keys. */ export declare function pickFromObject, K extends keyof T>({ obj, keys }: PickFromObjectParams): Pick; type OmitFromObjectParams, K extends keyof T> = { obj: T | undefined; keys: K[]; }; /** * Creates a new object excluding the specified keys from the original object. * * @template T The type of the object from which keys will be omitted. * @template K The type of the keys to omit from the object. * * @param {OmitFromObjectParams} params - An object containing the original object and the keys to omit. * @param {T | undefined} params.obj - The original object from which keys will be omitted. * @param {K[]} params.keys - An array of keys to omit from the object. * @returns {Omit} A new object excluding the omitted keys. */ export declare function omitFromObject, K extends keyof T>({ obj, keys }: OmitFromObjectParams): Omit; type PrependToObjectKeyReturn = { [P in keyof T as `${K}${string & P}`]: T[P]; }; /** * Creates a new object by prepending a specified string to each key of the original object. * * @param {object} obj - The original object whose keys will be modified. * @param {string} key - The string to prepend to each key. * @returns {object} A new object with modified keys. * * @example * const original = { name: 'Alice', age: 30 }; * const prepended = prependToObjectKey(original, 'user_'); * // Result: { user_name: 'Alice', user_age: 30 } */ export declare function prependToObjectKey, K extends string>(obj: T | null | undefined, key: K): PrependToObjectKeyReturn; type DeepPartial = { [P in keyof T]?: T[P] extends object ? DeepPartial : T[P]; }; type DeepMergeProps = { target: T; source: DeepPartial; }; /** * A TypeScript utility function to perform a deep merge of two objects, allowing for selective merging of nested properties. * * @param {object} target - The original object to merge into. * @param {object} source - The object containing updates. Only properties in `source` will overwrite target properties. * @returns {object} An object of type `T` with `target` properties overwritten by `source` properties where applicable. * * @example * const original = { * user: { * name: 'John', * address: { * city: 'New York', * zip: '10001' * } * } * }; * * const updates = { * user: { * address: { * city: 'San Francisco' * } * } * }; * * const merged = deepMerge({ target: original, source: updates }); * console.log(merged); * /* * { * user: { * name: 'John', * address: { * city: 'San Francisco', * zip: '10001' * } * } * } */ export declare function deepMerge({ target, source, }: DeepMergeProps): T; /** * Converts the provided data to a JSON-compatible format by replacing * big integers with either numbers or strings and reviving date strings * to Date objects. * * @param {object | object[]} data - The data to serialize. * @returns {object | object[]} - The serialized data. * * @example * const data = { * id: 1234567890123456789, * name: "John Doe", * date: "2022-01-01T12:00:00.000Z", * }; * * const jsonified = jsonify(data); * // Result: { id: "1234567890123456789", name: "John Doe", date: Date object } */ export declare function jsonify(data: T): T; export {};