super-utils-plus
Version:
A superior alternative to Lodash with improved performance, TypeScript support, and developer experience
27 lines (26 loc) • 849 B
TypeScript
import { DeepPartial } from '../utils/types';
/**
* Recursively merges own and inherited enumerable string keyed properties of source
* objects into the destination object. Source properties that resolve to undefined
* are skipped if a destination value exists. Array and plain object properties are
* merged recursively. Other objects and value types are overridden by assignment.
*
* @param object - The destination object
* @param sources - The source objects
* @returns The destination object
*
* @example
* ```ts
* const object = {
* 'a': [{ 'b': 2 }, { 'd': 4 }]
* };
*
* const other = {
* 'a': [{ 'c': 3 }, { 'e': 5 }]
* };
*
* merge(object, other);
* // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
* ```
*/
export declare function merge<T extends object>(object: T, ...sources: Array<DeepPartial<T>>): T;