forEachChild

external fun <T> forEachChild(node: Node, cbNode: (node: Node) -> T?, cbNodes: (nodes: NodeArray<Node>) -> T? = definedExternally): T?(source)

Invokes a callback for each child of the given node. The 'cbNode' callback is invoked for all child nodes stored in properties. If a 'cbNodes' callback is specified, it is invoked for embedded arrays; otherwise, embedded arrays are flattened and the 'cbNode' callback is invoked for each element. If a callback returns a truthy value, iteration stops and that value is returned. Otherwise, undefined is returned.

Parameters

node

a given node to visit its children

cbNode

a callback to be invoked for all child nodes

cbNodes

a callback to be invoked for embedded array