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

    Function destruct

    • Deconstruct the node and possibly empty forest of a tree. Useful in pipelines.

      Type Parameters

      • A

        Underlying tree type.

      Parameters

      • self: Tree<A>

        The tree being deconstructed.

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

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

      import * as Tree from 'effect-tree'

      const tree = Tree.tree(1, [Tree.leaf(2), Tree.leaf(3)])

      const [value, forest] = Tree.destruct(tree)

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