UNPKG

rc-js-util

Version:

A collection of TS and C++ utilities to help writing performant and correct applications, achieved through strict typing and (removable) invariant checking.

90 lines (42 loc) 1.25 kB
<!-- Do not edit this file. It is automatically generated by API Documenter. --> [Home](./index.md) &gt; [rc-js-util](./rc-js-util.md) &gt; [treeCollect](./rc-js-util.treecollect.md) ## treeCollect() function Similar to a reducer, but without the return requirement. It otherwise behaves like [treeIterate()](./rc-js-util.treeiterate.md)<!-- -->. **Signature:** ```typescript export declare function treeCollect<TRet, TNode extends ITreeNodeLike<TNode>>(node: TNode, collected: TRet, callback: (collected: TRet, node: TNode, parent: TNode | null, depth: number) => void): TRet; ``` ## Parameters <table><thead><tr><th> Parameter </th><th> Type </th><th> Description </th></tr></thead> <tbody><tr><td> node </td><td> TNode </td><td> The start point. </td></tr> <tr><td> collected </td><td> TRet </td><td> The reduced value. </td></tr> <tr><td> callback </td><td> (collected: TRet, node: TNode, parent: TNode \| null, depth: number) =&gt; void </td><td> Called for each node, including the start point. </td></tr> </tbody></table> **Returns:** TRet ## Remarks See [treeCollect()](./rc-js-util.treecollect.md)<!-- -->.