(a: Node, b: Node)
| 381 | } |
| 382 | |
| 383 | function 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 | |
| 401 | type ForbidUnion<A, Message extends string> = IsUnion<A> extends true ? [Message] : [] |
| 402 |
no test coverage detected