Skip to content

Latest commit

 

History

History
87 lines (68 loc) · 3.13 KB

api.md

File metadata and controls

87 lines (68 loc) · 3.13 KB

Functions

mutate(root, dataMutator, layoutMutator, [order])Object

Walk over a mutable tree and invoke mutators on each node.

Mutators implements mutations at 2 different levels:

  • data level: mutate node data
  • layout level: mutate node layout

Typedefs

DataMutatorObject | undefined | null

Mutate node data.

It treats the node atomically and only modifies its own properties. 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.

LayoutMutator : function

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.

mutate(root, dataMutator, layoutMutator, [order]) ⇒ Object

Walk over a mutable tree and invoke mutators on each node.

Mutators implements mutations at 2 different levels:

  • data level: mutate node data
  • layout level: mutate node layout

Kind: global function
Returns: Object - The mutated tree.

Param Type Description
root Object Root node of the tree.
dataMutator DataMutator Mutate node data.
layoutMutator LayoutMutator Mutate node layout.
[order] 'pre' | 'post' Walk order.

DataMutator ⇒ Object | undefined | null

Mutate node data.

It treats the node atomically and only modifies its own properties. 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.

Kind: global typedef
Returns: Object | undefined | null - The node itself, nothing or null.

Param Type Description
node Object Node to be mutated.
context Context Walk context.

LayoutMutator : function

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.

Kind: global typedef

Param Type Description
mutation 'identity' | 'replace' | 'remove' Type of layout mutation.
node Object | null Node to be mutated.
parentNode Object Parent of the node to be mutated.