UNPKG

@handy-common-utils/misc-utils

Version:
38 lines 1.71 kB
/** * Options to customize the merge behavior. */ export interface MergeOptions { /** * If `true`, the merge will be immutable, creating a new object. * If `false` or not provided, the destination object will be mutated. * @default false */ immutable?: boolean; /** * Defines how to handle arrays during the merge. * - `replace`: The source array completely replaces the destination array. * - `append`: The source array's elements are added to the end of the destination array. * - `merge`: (Default) Mimics Lodash's behavior. It overwrites elements at the same index. * If an element is an object, it merges them recursively. If the source array is longer, * its additional elements are appended. * @default 'merge' */ array?: 'replace' | 'append' | 'merge'; /** * Defines how to handle `Set` objects during the merge. * - `replace`: (Default) The source `Set` completely replaces the destination `Set`. * - `merge`: A new `Set` is created containing all elements from both the destination and source `Set`s. * @default 'replace' */ set?: 'replace' | 'merge'; } /** * Recursively merges properties of one or more source objects into a destination object. * * @param options - Customizes the merge behavior. * @param destination - The object to merge properties into. It will be mutated unless `options.immutable` is true. * @param sources - The source objects. * @returns The merged object. */ export declare function merge<T extends object, U extends any[]>(options: MergeOptions | null | undefined, destination: T, ...sources: U): T & (U[number]); //# sourceMappingURL=merge.d.ts.map