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

    Function destructBranch

    • Same as destruct but only for branches, so you are guaranteed a non-empty forest.

      Type Parameters

      • A

        Underlying tree type.

      Parameters

      • self: Branch<A>

        The branch being deconstructed.

      Returns [A, readonly [Tree<A>, Tree<A>]]

      A pair of the tree node value and a non-empty list of child trees.

      import * as Tree from 'effect-tree'

      const branch: Tree.Branch<number> = Tree.branch(1, [Tree.of(2), Tree.of(3)])

      const [value, forest] = Tree.destructBranch(branch)

      expect(value, 'value').toBe(1)
      expect(forest, 'forest').toEqual([Tree.of(2), Tree.of(3)])