Function hasSomeDescendant

  • Returns whether any of the descendants of the given node fulfill the given condition.

    The descendants will be iterated in a DFS top-to-bottom manner from left to right with the first node being the given node.

    If the given condition is an AST node instead of a function, hasSomeDescendant will behave as if the condition function was d => d === conditionNode.

    This function is short-circuited, so as soon as any condition returns true, true will be returned.

    Type Parameters

    • T extends Node

    Parameters

    • node: T
    • condition: Node | ((descendant) => boolean)
    • Optional descentConditionFn: ((descendant) => boolean)

      An optional function to decide whether the descendant of the given node will be checked as well.

      This function will be called with some node only after condition has returned false for this node.

        • (descendant): boolean
        • Parameters

          Returns boolean

    Returns boolean