MCPcopy
hub / github.com/angular/angular / getChild

Method getChild

packages/forms/signals/src/schema/logic_node.ts:371–395  ·  view source on GitHub ↗

* Retrieves the `LogicNode` for a child identified by the given property key. * @param key The property key of the child. * @returns The `LogicNode` for the specified child.

(key: PropertyKey)

Source from the content-addressed store, hash-verified

369 * @returns The `LogicNode` for the specified child.
370 */
371 getChild(key: PropertyKey): LogicNode {
372 // The logic for a particular child may be spread across multiple builders. We lazily combine
373 // this logic at the time the child logic node is requested to be created.
374 const childBuilders = this.builder ? getAllChildBuilders(this.builder, key) : [];
375 if (childBuilders.length === 0) {
376 return new LeafLogicNode(undefined, [], this.depth + 1);
377 } else if (childBuilders.length === 1) {
378 const {builder, predicates} = childBuilders[0];
379 return new LeafLogicNode(
380 builder,
381 [...this.predicates, ...predicates.map((p) => bindLevel(p, this.depth))],
382 this.depth + 1,
383 );
384 } else {
385 const builtNodes = childBuilders.map(
386 ({builder, predicates}) =>
387 new LeafLogicNode(
388 builder,
389 [...this.predicates, ...predicates.map((p) => bindLevel(p, this.depth))],
390 this.depth + 1,
391 ),
392 );
393 return new CompositeLogicNode(builtNodes);
394 }
395 }
396
397 hasLogic(builder: AbstractLogicNodeBuilder): boolean {
398 if (!this.builder) {

Callers

nothing calls this directly

Calls 3

getAllChildBuildersFunction · 0.85
bindLevelFunction · 0.85
mapMethod · 0.80

Tested by

no test coverage detected