effect-tree
    Preparing search index...

    Function repeatUntilValue

    • Repeat the given navigation function of type Zipper<A> ⇒ Option<Zipper<A>> on the focus node iteratively, updating the focus node with the result until the focus node value meets the given predicate or the navigation terminates by returning Option.none, for example when reaching the last element of a forest with the tryNext navigation, or the final depth-first node of the tree with tryDepthFirst navigation.

      If the predicate matched, then the zipper is returned pointing at the matching tree node. If it did not, returns Option.none.

      If a cycle in navigation is detected a runtime exception is thrown. Cycles are detected by checking no node is visited twice, so if your navigation does this it will throw a runtime exception even if there are no actual cycles in the navigation. Keep your navigation pointing one way, for example depth first, to avoid creating cycles.

      See repeatUntil for a version that matches on the focused tree node and not just its value which allows you, for example, to test the node children.

      Type Parameters

      • A

        The underlying type of the tree.

      Parameters

      • navigation: OptionalZipper

        A function that takes a zipper and returns either an updated zipper focused on a different tree node, or Option.none.

      • predicate: Predicate<A>

        Will be matched against every tree node reached by the navigation.

      Returns OptionalZipperOf<A>

      An updated zipper if the search criteria matched an element along the navigation given, else Option.none.