effect-tree - v1.0.36
    Preparing search index...

    Function getDepth

    • Get the depth of the zipper, where a zipper focused on the root node gets a depth of 0.

      Type Parameters

      • A

        Underlying tree type.

      Parameters

      Returns number

      Integer depth of the zipper.

      import {Zipper, from, of} from 'effect-tree'

      const tree = from(1, of(2), of(3))

      const zipper = Zipper.fromTree(tree)

      expect(Zipper.getDepth(zipper)).toBe(0)

      const moved = Zipper.head(zipper)

      expect(Zipper.getDepth(moved)).toBe(1)