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

Function compose

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

Source from the content-addressed store, hash-verified

381}
382
383function compose(a: Node, b: Node): Node {
384 if (a.length === 0) return b
385 if (b.length === 0) return a
386 const nodes = a.slice()
387 for (let i = 0; i < b.length; i++) {
388 const node = b[i]
389 const last = nodes[nodes.length - 1]
390 if (last._tag === "PathNode" && node._tag === "PathNode") {
391 nodes[nodes.length - 1] = new PathNode([...last.path, ...node.path])
392 } else if (last._tag === "CheckNode" && node._tag === "CheckNode") {
393 nodes[nodes.length - 1] = new CheckNode<any>([...last.checks, ...node.checks])
394 } else {
395 nodes.push(node)
396 }
397 }
398 return nodes
399}
400
401type ForbidUnion<A, Message extends string> = IsUnion<A> extends true ? [Message] : []
402

Callers 9

serveFunction · 0.90
toWebHandlerFunction · 0.90
composeMethod · 0.70
keyMethod · 0.70
optionalKeyMethod · 0.70
checkMethod · 0.70
refineMethod · 0.70
tagMethod · 0.70
atMethod · 0.70

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected