import { collect } from '@daffodil/core'
Recurses through a tree, collecting each element in that tree and returning it in an array. The value of getKey should be a field that contains a list of the same type of object. Accepts an optional depth argument which will limit the traversal. This should be used for trees with circular references.
function collect<T>(
obj: T
getChildren: (val: T) => T[]
depth?: number
): T[]
| Parameter | obj: T |
|---|---|
| Description |
| Parameter | getChildren: (val: T) => T[] |
|---|---|
| Description |
| Parameter | depth: number |
|---|---|
| Description |