es-next-tools
Version:
A comprehensive utility library for JavaScript and TypeScript that provides a wide range of functions for common programming tasks, including mathematical operations, date manipulations, array and object handling, string utilities, and more.
13 lines (12 loc) • 531 B
TypeScript
/**
* Deeply merges multiple objects into a target object.
* @param {T} target - The target object to merge into.
* @param {...Partial<S>[]} sources - The source objects to merge from.
* @returns The merged object.
* @example
* const obj1 = { a: { b: 2 }, c: 3 };
* const obj2 = { a: { d: 4 }, e: 5 };
* const merged = mergeDeep(obj1, obj2);
* // { a: { b: 2, d: 4 }, c: 3, e: 5 }
*/
export declare function mergeDeep<T extends Record<string, any>, S extends Record<string, any>[]>(target: T, ...sources: Partial<S>): T;