MCPcopy Index your code
hub / github.com/Effect-TS/effect / compactUnion

Function compactUnion

packages/effect/src/JSONSchema.ts:1029–1047  ·  view source on GitHub ↗
(members: Array<JsonSchema7>)

Source from the content-addressed store, hash-verified

1027}
1028
1029function compactUnion(members: Array<JsonSchema7>): Array<JsonSchema7> {
1030 const out: Array<JsonSchema7> = []
1031 for (const m of members) {
1032 if (isNeverWithoutCustomAnnotations(m)) continue
1033 if (isAny(m) || isUnknown(m) || isVoid(m)) return [m]
1034 if (isCompactableLiteral(m) && out.length > 0) {
1035 const last = out[out.length - 1]
1036 if (isCompactableLiteral(last) && last.type === m.type) {
1037 out[out.length - 1] = {
1038 type: last.type,
1039 enum: [...last.enum, ...m.enum]
1040 } as JsonSchema7Enum
1041 continue
1042 }
1043 }
1044 out.push(m)
1045 }
1046 return out
1047}

Callers 1

goFunction · 0.85

Calls 5

isAnyFunction · 0.85
isCompactableLiteralFunction · 0.85
isUnknownFunction · 0.70
isVoidFunction · 0.70

Tested by

no test coverage detected