merge-left-utils
Version:
Merge objects without structure changes
10 lines (8 loc) • 402 B
TypeScript
import type { DeepPartial } from './util';
/**
Shortcut function
Replace only existing fields in {a} with {b}
When field from {b} is truthy
ex: ({ a: 0, b: 0 }, { a: 1, x: 1 }) -> { a: 1, b: 0 }
*/
export declare function mergeLeftTruthy<T extends Record<string, any>>(source: T, target?: DeepPartial<T>, customLogic?: (key: keyof T, source: T, target: DeepPartial<T>) => boolean): T;