MCPcopy
hub / github.com/angular/angular / createLogic

Function createLogic

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

* Creates the full `Logic` for a given builder. * This function handles different types of builders (`LogicNodeBuilder`, `NonMergeableLogicNodeBuilder`) * and applies the provided predicates. * @param builder The `AbstractLogicNodeBuilder` to process. * @param predicates Predicates to apply to t

(
  builder: AbstractLogicNodeBuilder,
  predicates: BoundPredicate[],
  depth: number,
)

Source from the content-addressed store, hash-verified

510 * @returns The `Logic` instance.
511 */
512function createLogic(
513 builder: AbstractLogicNodeBuilder,
514 predicates: BoundPredicate[],
515 depth: number,
516): LogicContainer {
517 const logic = new LogicContainer(predicates);
518 if (builder instanceof LogicNodeBuilder) {
519 const builtNodes = builder.all.map(
520 ({builder, predicate}) =>
521 new LeafLogicNode(
522 builder,
523 predicate ? [...predicates, bindLevel(predicate, depth)] : predicates,
524 depth,
525 ),
526 );
527 for (const node of builtNodes) {
528 logic.mergeIn(node.logic);
529 }
530 } else if (builder instanceof NonMergeableLogicNodeBuilder) {
531 logic.mergeIn(builder.logic);
532 } else {
533 throw new RuntimeError(
534 RuntimeErrorCode.UNKNOWN_BUILDER_TYPE,
535 ngDevMode && 'Unknown LogicNodeBuilder type',
536 );
537 }
538 return logic;
539}
540
541/**
542 * Create a bound version of the given predicate to a specific depth in the field tree.

Callers 1

constructorMethod · 0.85

Calls 3

mergeInMethod · 0.95
bindLevelFunction · 0.85
mapMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…