• Finds the first node that satisfies a condition among a node's descendants.

    Parameters

    • startingNode: Node

      the node which is the root of the subtree.

    • predicate: ((n, index) => boolean)

      the function expressing the condition that the node must satisfy.

        • (n, index): boolean
        • Parameters

          • n: Node
          • index: number

          Returns boolean

    • walker: ((node) => Generator<Node>) = walk

      the function that generates the nodes to operate on in the desired sequence. By default, this is a depth-first traversal that includes the starting node.

        • (node): Generator<Node>
        • A generator that walks the whole AST starting from the provided node, depth-first.

          Parameters

          • node: Node

            the starting node.

          Returns Generator<Node>

    Returns Node | undefined

    the first node in the AST for which the predicate is true. Returns undefined if none are found.

Generated using TypeDoc