MCPcopy
hub / github.com/di-sukharev/opencommit / mergeValues

Function mergeValues

out/cli.cjs:31719–31756  ·  view source on GitHub ↗
(a4, b7)

Source from the content-addressed store, hash-verified

31717 };
31718 exports2.ZodDiscriminatedUnion = ZodDiscriminatedUnion;
31719 function mergeValues(a4, b7) {
31720 const aType = (0, util_1.getParsedType)(a4);
31721 const bType = (0, util_1.getParsedType)(b7);
31722 if (a4 === b7) {
31723 return { valid: true, data: a4 };
31724 } else if (aType === util_1.ZodParsedType.object && bType === util_1.ZodParsedType.object) {
31725 const bKeys = util_1.util.objectKeys(b7);
31726 const sharedKeys = util_1.util.objectKeys(a4).filter((key) => bKeys.indexOf(key) !== -1);
31727 const newObj = { ...a4, ...b7 };
31728 for (const key of sharedKeys) {
31729 const sharedValue = mergeValues(a4[key], b7[key]);
31730 if (!sharedValue.valid) {
31731 return { valid: false };
31732 }
31733 newObj[key] = sharedValue.data;
31734 }
31735 return { valid: true, data: newObj };
31736 } else if (aType === util_1.ZodParsedType.array && bType === util_1.ZodParsedType.array) {
31737 if (a4.length !== b7.length) {
31738 return { valid: false };
31739 }
31740 const newArray = [];
31741 for (let index = 0; index < a4.length; index++) {
31742 const itemA = a4[index];
31743 const itemB = b7[index];
31744 const sharedValue = mergeValues(itemA, itemB);
31745 if (!sharedValue.valid) {
31746 return { valid: false };
31747 }
31748 newArray.push(sharedValue.data);
31749 }
31750 return { valid: true, data: newArray };
31751 } else if (aType === util_1.ZodParsedType.date && bType === util_1.ZodParsedType.date && +a4 === +b7) {
31752 return { valid: true, data: a4 };
31753 } else {
31754 return { valid: false };
31755 }
31756 }
31757 var ZodIntersection = class extends ZodType {
31758 _parse(input) {
31759 const { status, ctx } = this._processInputParams(input);

Callers 1

handleParsedMethod · 0.85

Calls 2

filterMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…