Mutate node data.
It treats the node atomically and create a deep clone of it.
Structural properties should be left untouched and modified in the layout
mutator instead.
If null
is returned, the node is marked as removed and processed by the
layout mutator.
Type: Function
Parameters
node
Object Node to be mutated.context
Context Walk context.
Returns (Object | undefined | null) The node itself, nothing or null
.
Mutate node layout.
It treats the node as a black box that has a position in the tree. It modifies its structural properties and may alter ancestors, siblings or descendants nodes.
Type: Function
Parameters
Walk over an immutable tree and invoke mutators on each node.
Mutators implements mutations at 2 different levels:
- data level: mutate node data
- layout level: mutate node layout
Parameters
root
Object Root node of the tree.dataMutator
DataMutator Mutate node data.layoutMutator
LayoutMutator Mutate node layout.
Returns Object The mutated tree.