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

    Function modBranch

    Run the given function over the given tree if it is a branch, else return the tree unchanged. This is like match where the onLeaf branch is set to identity.

    import * as Tree from 'effect-tree'

    const leaf = Tree.of(1)
    const branch = Tree.from(2, leaf)

    const changeBranch = Tree.modBranch(Tree.setValue(3))

    expect(changeBranch(leaf), 'leaf').toEqual(leaf)
    expect(changeBranch(branch), 'branch').toEqual(Tree.from(3, leaf))

    Underlying tree type.

    Tree on which to run the given function.

    A function from Branch to Tree.

    The tree unchanged if it is a leaf, else the result of applying the given function on the branch.