UNPKG

ts-prime

Version:

A utility library for JavaScript and Typescript.

43 lines 1.69 kB
import { DeepPartial } from './types'; /** * Merging object from left to right * * @param target - value be preserved if possible. * @param sources - value be preserved if possible. * @description * Consider following * * - `array + obj = array` * - `obj + array = obj` * - `obj + obj = obj` (recursively merged) * - `array + array = array` (removes duplicates using Set) * - `(truthy plain value) + ob = (truthy plain value)` * - `(truthy plain value) + undefined = (truthy plain value)` * - `A(truthy plain value) + B(truthy plain value) = A(truthy plain value)` * - `undefined + B(truthy plain value) = B(truthy plain value)` * - `null + B(truthy plain value) = B(truthy plain value)` * * * Handles circular references * @category Utility */ export declare function deepMergeLeft<T extends object, X extends DeepPartial<T>>(data: T, ...source: X[]): T; export declare function deepMergeLeft<T extends object>(...sources: T[]): T; /** * Merging object from right to left * * @param target value will be replaced if possible. * @description * Consider following * - `array + obj = obj` * - `obj + array = array` * - `obj + obj = obj` (recursively merged) * - `array + array = array` (removes duplicates using Set) * - `(truthy plain value) + undefined = (truthy plain value)` * - `A(truthy plain value) + B(truthy plain value) = B(truthy plain value)` * Handles circular references * @category Utility */ export declare function deepMergeRight<T extends object, X extends DeepPartial<T>>(data: T, ...source: X[]): T; export declare function deepMergeRight<T extends object>(...sources: T[]): T; //# sourceMappingURL=deepMerge.d.ts.map