You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+21-2Lines changed: 21 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -59,8 +59,8 @@ Which results in the following array:
59
59
60
60
You can provide a second argument to arrayToTree with configuration options. Right now, you can set the following:
61
61
62
-
-`id`: key of the id field of the item. Default: `"id"`
63
-
-`parentId`: key of the parent's id field of the item. Default: `"parentId"`
62
+
-`id`: key of the id field of the item. Also works with nested properties (e. g. `"nested.parentId"`). Default: `"id"`.
63
+
-`parentId`: key of the parent's id field of the item. Also works with nested properties (e. g. `"nested.parentId"`). Default: `"parentId"`.
64
64
-`childrenField`: key which will contain all child nodes of the parent node. Default: `"children"`
65
65
-`dataField`: key which will contain all properties/data of the original items. Set to null if you don't want a container. Default: `"data"`
66
66
-`throwIfOrphans`: option to throw an error if the array of items contains one or more items that have no parents in the array. This option has a small runtime penalty, so it's disabled by default. When enabled, the function will throw an error containing the parentIds that were not found in the items array. When disabled, the function will just ignore orphans and not add them to the tree. Default: `false`
0 commit comments