UNPKG

merge-left-utils

Version:

Merge objects without structure changes

15 lines (13 loc) 693 B
import type { DeepPartial } from './util'; /** Function merge objects {a} and {b} by [keys] If key from {b} is not presented in {a} - it does nothing If both objects has key - result will get key from {b} if value is seems like object - then we run function recursive for value keys - which keys will be checked for objects a - left b - right customLogic (a[key], target[key]) : boolean - if it returns true - then get value from {b}, else from {a} */ export declare function mergeLeftKeys<T extends Record<string, any>>(keys: Array<keyof T>, source: T, target?: DeepPartial<T>, customLogic?: (key: keyof T, source: T, target: DeepPartial<T>) => boolean): T;