| 1 | type MergeWithCustomizer = (objValue: any, srcValue: any, key: string, object: any, source: any, stack: any) => any;
|
|---|
| 2 | /**
|
|---|
| 3 | * Merges the properties of a source object into the target object using a customizer function.
|
|---|
| 4 | *
|
|---|
| 5 | * @template TObject
|
|---|
| 6 | * @template TSource
|
|---|
| 7 | * @param {TObject} object - The target object into which the source object properties will be merged.
|
|---|
| 8 | * @param {TSource} source - The source object whose properties will be merged into the target object.
|
|---|
| 9 | * @param {MergeWithCustomizer} customizer - The function to customize assigned values.
|
|---|
| 10 | * @returns {TObject & TSource} Returns the updated target object with properties from the source object merged in.
|
|---|
| 11 | *
|
|---|
| 12 | * @example
|
|---|
| 13 | * const target = { a: 1, b: 2 };
|
|---|
| 14 | * const source = { b: 3, c: 4 };
|
|---|
| 15 | *
|
|---|
| 16 | * const result = mergeWith(target, source, (objValue, srcValue) => {
|
|---|
| 17 | * if (typeof objValue === 'number' && typeof srcValue === 'number') {
|
|---|
| 18 | * return objValue + srcValue;
|
|---|
| 19 | * }
|
|---|
| 20 | * });
|
|---|
| 21 | * // => { a: 1, b: 5, c: 4 }
|
|---|
| 22 | */
|
|---|
| 23 | declare function mergeWith<TObject, TSource>(object: TObject, source: TSource, customizer: MergeWithCustomizer): TObject & TSource;
|
|---|
| 24 | /**
|
|---|
| 25 | * Merges the properties of two source objects into the target object using a customizer function.
|
|---|
| 26 | *
|
|---|
| 27 | * @template TObject
|
|---|
| 28 | * @template TSource1
|
|---|
| 29 | * @template TSource2
|
|---|
| 30 | * @param {TObject} object - The target object into which the source objects properties will be merged.
|
|---|
| 31 | * @param {TSource1} source1 - The first source object.
|
|---|
| 32 | * @param {TSource2} source2 - The second source object.
|
|---|
| 33 | * @param {MergeWithCustomizer} customizer - The function to customize assigned values.
|
|---|
| 34 | * @returns {TObject & TSource1 & TSource2} Returns the updated target object with properties from the source objects merged in.
|
|---|
| 35 | *
|
|---|
| 36 | * @example
|
|---|
| 37 | * const target = { a: 1 };
|
|---|
| 38 | * const source1 = { b: 2 };
|
|---|
| 39 | * const source2 = { c: 3 };
|
|---|
| 40 | *
|
|---|
| 41 | * const result = mergeWith(target, source1, source2, (objValue, srcValue) => {
|
|---|
| 42 | * if (typeof objValue === 'number' && typeof srcValue === 'number') {
|
|---|
| 43 | * return objValue + srcValue;
|
|---|
| 44 | * }
|
|---|
| 45 | * });
|
|---|
| 46 | * // => { a: 1, b: 2, c: 3 }
|
|---|
| 47 | */
|
|---|
| 48 | declare function mergeWith<TObject, TSource1, TSource2>(object: TObject, source1: TSource1, source2: TSource2, customizer: MergeWithCustomizer): TObject & TSource1 & TSource2;
|
|---|
| 49 | /**
|
|---|
| 50 | * Merges the properties of three source objects into the target object using a customizer function.
|
|---|
| 51 | *
|
|---|
| 52 | * @template TObject
|
|---|
| 53 | * @template TSource1
|
|---|
| 54 | * @template TSource2
|
|---|
| 55 | * @template TSource3
|
|---|
| 56 | * @param {TObject} object - The target object into which the source objects properties will be merged.
|
|---|
| 57 | * @param {TSource1} source1 - The first source object.
|
|---|
| 58 | * @param {TSource2} source2 - The second source object.
|
|---|
| 59 | * @param {TSource3} source3 - The third source object.
|
|---|
| 60 | * @param {MergeWithCustomizer} customizer - The function to customize assigned values.
|
|---|
| 61 | * @returns {TObject & TSource1 & TSource2 & TSource3} Returns the updated target object with properties from the source objects merged in.
|
|---|
| 62 | *
|
|---|
| 63 | * @example
|
|---|
| 64 | * const target = { a: 1 };
|
|---|
| 65 | * const source1 = { b: 2 };
|
|---|
| 66 | * const source2 = { c: 3 };
|
|---|
| 67 | * const source3 = { d: 4 };
|
|---|
| 68 | *
|
|---|
| 69 | * const result = mergeWith(target, source1, source2, source3, (objValue, srcValue) => {
|
|---|
| 70 | * if (typeof objValue === 'number' && typeof srcValue === 'number') {
|
|---|
| 71 | * return objValue + srcValue;
|
|---|
| 72 | * }
|
|---|
| 73 | * });
|
|---|
| 74 | * // => { a: 1, b: 2, c: 3, d: 4 }
|
|---|
| 75 | */
|
|---|
| 76 | declare function mergeWith<TObject, TSource1, TSource2, TSource3>(object: TObject, source1: TSource1, source2: TSource2, source3: TSource3, customizer: MergeWithCustomizer): TObject & TSource1 & TSource2 & TSource3;
|
|---|
| 77 | /**
|
|---|
| 78 | * Merges the properties of four source objects into the target object using a customizer function.
|
|---|
| 79 | *
|
|---|
| 80 | * @template TObject
|
|---|
| 81 | * @template TSource1
|
|---|
| 82 | * @template TSource2
|
|---|
| 83 | * @template TSource3
|
|---|
| 84 | * @template TSource4
|
|---|
| 85 | * @param {TObject} object - The target object into which the source objects properties will be merged.
|
|---|
| 86 | * @param {TSource1} source1 - The first source object.
|
|---|
| 87 | * @param {TSource2} source2 - The second source object.
|
|---|
| 88 | * @param {TSource3} source3 - The third source object.
|
|---|
| 89 | * @param {TSource4} source4 - The fourth source object.
|
|---|
| 90 | * @param {MergeWithCustomizer} customizer - The function to customize assigned values.
|
|---|
| 91 | * @returns {TObject & TSource1 & TSource2 & TSource3 & TSource4} Returns the updated target object with properties from the source objects merged in.
|
|---|
| 92 | *
|
|---|
| 93 | * @example
|
|---|
| 94 | * const target = { a: 1 };
|
|---|
| 95 | * const source1 = { b: 2 };
|
|---|
| 96 | * const source2 = { c: 3 };
|
|---|
| 97 | * const source3 = { d: 4 };
|
|---|
| 98 | * const source4 = { e: 5 };
|
|---|
| 99 | *
|
|---|
| 100 | * const result = mergeWith(target, source1, source2, source3, source4, (objValue, srcValue) => {
|
|---|
| 101 | * if (typeof objValue === 'number' && typeof srcValue === 'number') {
|
|---|
| 102 | * return objValue + srcValue;
|
|---|
| 103 | * }
|
|---|
| 104 | * });
|
|---|
| 105 | * // => { a: 1, b: 2, c: 3, d: 4, e: 5 }
|
|---|
| 106 | */
|
|---|
| 107 | declare function mergeWith<TObject, TSource1, TSource2, TSource3, TSource4>(object: TObject, source1: TSource1, source2: TSource2, source3: TSource3, source4: TSource4, customizer: MergeWithCustomizer): TObject & TSource1 & TSource2 & TSource3 & TSource4;
|
|---|
| 108 | /**
|
|---|
| 109 | * Merges the properties of one or more source objects into the target object.
|
|---|
| 110 | *
|
|---|
| 111 | * @param {any} object - The target object into which the source object properties will be merged.
|
|---|
| 112 | * @param {...any} otherArgs - Additional source objects to merge into the target object, including the custom `merge` function.
|
|---|
| 113 | * @returns {any} The updated target object with properties from the source object(s) merged in.
|
|---|
| 114 | *
|
|---|
| 115 | * @example
|
|---|
| 116 | * const target = { a: 1, b: 2 };
|
|---|
| 117 | * const source = { b: 3, c: 4 };
|
|---|
| 118 | *
|
|---|
| 119 | * const result = mergeWith(target, source, (objValue, srcValue) => {
|
|---|
| 120 | * if (typeof objValue === 'number' && typeof srcValue === 'number') {
|
|---|
| 121 | * return objValue + srcValue;
|
|---|
| 122 | */
|
|---|
| 123 | declare function mergeWith(object: any, ...otherArgs: any[]): any;
|
|---|
| 124 |
|
|---|
| 125 | export { mergeWith };
|
|---|