Skip to content

Commit 5e9b2ee

Browse files
authored
Update README.md
1 parent 6e40b1c commit 5e9b2ee

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,17 @@ fetch('https://raw.githubusercontent.com/internet5/smart-array-to-tree/master/ex
2929
//2017-11-21T09:51:37.930Z
3030
//2017-11-21T09:51:37.979Z
3131
```
32+
## API
33+
### `smartArrayToTree(data, [options])`
34+
Convert a plain array of nodes (with pointers to parent nodes) to a a nested data structure.
35+
36+
#### Parameters
37+
- **Array** `data`: An array of data
38+
- **Object** `options`: An object containing the following fields:
39+
 - `id` (String): An unique node identifier. Default: 'id'
40+
 - `pid` (String): A name of a property where a link to a parent node could be found. Default: 'pid'
41+
 - `children` (String): The child node name that you want. Default: 'children'
42+
 - `firstPid` (String): The parent id of fisrt level node . Default: null
43+
44+
#### Return
45+
- **Array**: Result of transformation

0 commit comments

Comments
 (0)