SPeCS Packages Documentation
    Preparing search index...

    The class with functionality for the base node type.

    Type Parameters

    Hierarchy (View Summary)

    Index

    Accessors

    • get degree(): number

      Returns the number of edges connected to this node. Loop edges are counted twice.

      Returns number

      the degree of this node.

    • get degreeWithoutLoops(): number

      Returns the number of edges connected to this node. Loop edges are not counted.

      Returns number

      the degree of this node, excluding loop edges.

    • get functionName(): string

      Returns string

      The name of the function. This name must be unique in the graph, so it should be mangled if the use case permits overloading.

    • get indegree(): number

      Returns the number of edges that are directed towards this node.

      Returns number

      the indegree of this node.

    • get indegreeWithoutLoops(): number

      Returns the number of edges that are directed towards this node. Loop edges are not counted.

      Returns number

      the indegree of this node, excluding loop edges.

    • get isChild(): boolean

      Returns boolean

      whether this node is a child node.

    • get isParent(): boolean

      Returns boolean

      whether this node is a parent node.

    • get isRemoved(): boolean

      Returns boolean

      whether this node has been removed from the graph.

    • get outdegree(): number

      Returns the number of edges that are directed away from this node.

      Returns number

      the outdegree of this node.

    • get outdegreeWithoutLoops(): number

      Returns the number of edges that are directed away from this node. Loop edges are not counted.

      Returns number

      the outdegree of this node, excluding loop edges.

    Methods

    • Initializes the node with the information of a builder. This is effectively extends the type of the node to include the data and scratch data of the builder.

      The same node may simultaneously be of multiple types, as long as the data and scratch data are compatible with the types. The builder methods may overwrite data and scratch data fields with names that collide with its type's fields.

      Type Parameters

      Parameters

      Returns BaseNode.Class<D2, S2>

      The same node, with the data and scratch data of the builder. The node is downcasted to BaseNode.Class because the builder may overwrite the data and scratch data fields, invalidating the current type.

    • Registers the function in the graph, so that its name points to this node.

      Returns void

      LaraFlowError if the node is not part of a FlowGraph or if another function with the same name is already registered in the graph.

    • Changes the function name. This name must be unique in the graph, so it should be mangled if the use case permits overloading.

      The graph's function map will be updated.

      Parameters

      • name: string

        The new name of the function.

      Returns this

      Itself, for chaining.

      LaraFlowError if the new function name already exists in the graph. This should be seen as a logic error and should not be catched. Instead, ensure that no existing function shares the same name by renaming or removing.

    • Tries to change the functionality class of the current node. If the node is not compatible with the new class, undefined is returned.

      Type Parameters

      Parameters

      • NodeType: Node<D2, S2, N2>

        The node type to change the functionality class into.

      Returns N2 | undefined

      The node, wrapped in the new functionality class, or undefined if the node is not compatible with the type.

      if (node === undefined || !node.is(ControlFlowNode)) {
      return undefined;
      }
      return node.as(ControlFlowNode);

      Can be simplified to:

      return node?.tryAs(ControlFlowNode);