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

Class Union

packages/effect/src/SchemaAST.ts:1701–1730  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1699 * @since 3.10.0
1700 */
1701export class Union<M extends AST = AST> implements Annotated {
1702 static make = (types: ReadonlyArray<AST>, annotations?: Annotations): AST => {
1703 return isMembers(types) ? new Union(types, annotations) : types.length === 1 ? types[0] : neverKeyword
1704 }
1705 /** @internal */
1706 static unify = (candidates: ReadonlyArray<AST>, annotations?: Annotations): AST => {
1707 return Union.make(unify(flatten(candidates)), annotations)
1708 }
1709 /**
1710 * @since 3.10.0
1711 */
1712 readonly _tag = "Union"
1713 private constructor(readonly types: Members<M>, readonly annotations: Annotations = {}) {}
1714 /**
1715 * @since 3.10.0
1716 */
1717 toString() {
1718 return Option.getOrElse(getExpected(this), () => this.types.map(String).join(" | "))
1719 }
1720 /**
1721 * @since 3.10.0
1722 */
1723 toJSON(): object {
1724 return {
1725 _tag: this._tag,
1726 types: this.types.map((ast) => ast.toJSON()),
1727 annotations: toJSONAnnotations(this.annotations)
1728 }
1729 }
1730}
1731
1732/** @internal */
1733export const mapMembers = <A, B>(members: Members<A>, f: (a: A) => B): Members<B> => members.map(f) as any

Callers

nothing calls this directly

Calls 4

isMembersFunction · 0.85
unifyFunction · 0.85
flattenFunction · 0.70
makeMethod · 0.65

Tested by

no test coverage detected