MCPcopy
hub / github.com/vpulim/node-soap / baseMergeValue

Function baseMergeValue

src/utils.ts:44–83  ·  view source on GitHub ↗
(target: Record<string, any>, source: Record<string, any>, key: string, customizer?: (a: any, b: any, key: string) => any)

Source from the content-addressed store, hash-verified

42}
43
44function baseMergeValue(target: Record<string, any>, source: Record<string, any>, key: string, customizer?: (a: any, b: any, key: string) => any): void {
45 const srcValue = source[key];
46 const objValue = target[key];
47
48 if (customizer) {
49 const customResult = customizer(objValue, srcValue, key);
50 if (customResult !== undefined) {
51 target[key] = customResult;
52 return;
53 }
54 }
55
56 if (srcValue === undefined) {
57 return;
58 }
59
60 if (isPlainObject(srcValue)) {
61 if (isPlainObject(objValue)) {
62 for (const k of Object.keys(srcValue)) {
63 baseMergeValue(objValue as Record<string, any>, srcValue as Record<string, any>, k, customizer);
64 }
65 } else {
66 target[key] = merge({}, srcValue);
67 }
68 } else if (Array.isArray(srcValue)) {
69 if (Array.isArray(objValue)) {
70 for (let i = 0; i < srcValue.length; i++) {
71 if (isPlainObject(srcValue[i]) && isPlainObject(objValue[i])) {
72 merge(objValue[i], srcValue[i]);
73 } else if (srcValue[i] !== undefined) {
74 objValue[i] = srcValue[i];
75 }
76 }
77 } else {
78 target[key] = srcValue.slice();
79 }
80 } else {
81 target[key] = srcValue;
82 }
83}
84
85export function defaults<T>(target: T, ...sources: any[]): T {
86 for (const source of sources) {

Callers 1

mergeWithFunction · 0.85

Calls 2

isPlainObjectFunction · 0.85
mergeFunction · 0.85

Tested by

no test coverage detected