MCPcopy Create free account
hub / github.com/Effect-TS/effect / compose

Function compose

packages/effect/src/Optic.ts:392–408  ·  view source on GitHub ↗
(a: Node, b: Node)

Source from the content-addressed store, hash-verified

390}
391
392function compose(a: Node, b: Node): Node {
393 if (a.length === 0) return b
394 if (b.length === 0) return a
395 const nodes = a.slice()
396 for (let i = 0; i < b.length; i++) {
397 const node = b[i]
398 const last = nodes[nodes.length - 1]
399 if (last._tag === "PathNode" && node._tag === "PathNode") {
400 nodes[nodes.length - 1] = new PathNode([...last.path, ...node.path])
401 } else if (last._tag === "CheckNode" && node._tag === "CheckNode") {
402 nodes[nodes.length - 1] = new CheckNode<any>([...last.checks, ...node.checks])
403 } else {
404 nodes.push(node)
405 }
406 }
407 return nodes
408}
409
410type ForbidUnion<A, Message extends string> = IsUnion<A> extends true ? [Message] : []
411

Callers 8

composeMethod · 0.70
keyMethod · 0.70
optionalKeyMethod · 0.70
checkMethod · 0.70
refineMethod · 0.70
tagMethod · 0.70
atMethod · 0.70
SchemaGetter.tsFile · 0.70

Calls 2

sliceMethod · 0.80
pushMethod · 0.65

Tested by

no test coverage detected