Skip to content

Commit 51863cc

Browse files
author
Philipp Alferov
committed
Update documentation
1 parent 802fc63 commit 51863cc

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ function orderByParents(list, config) {
4545
*
4646
* - `parentProperty` (String): A name of a property where a link to
4747
* a parent node could be found. Default: 'parent_id'
48-
* - `data` (Array): An array with data
48+
* - `data` (Array): An array of data
4949
* - `customID` (String): An unique node identifier. Default: 'id'
5050
*
5151
* @return {Array} Result of transformation

readme.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ var navigation = [{
3333
parent_id: null
3434
}];
3535

36-
var navigationTree = arrayToTree({ data: navigation });
37-
3836
/*
3937
* Output:
4038
* Portfolio
@@ -43,9 +41,23 @@ var navigationTree = arrayToTree({ data: navigation });
4341
* About Me
4442
*/
4543

44+
var navigationTree = arrayToTree({ data: navigation });
4645
```
4746

47+
## Documentation
48+
49+
### `arrayToTree(options)`
50+
Convert a plain array of nodes (with pointers to parent nodes) to a tree.
51+
52+
#### Params
53+
**Object** `options`: An object containing the following fields:
54+
- `parentProperty` (String): A name of a property where a link to a parent node could be found. Default: 'parent_id'
55+
- `data` (Array): An array of` data
56+
- `customID` (String): An unique node identifier. Default: 'id'
57+
58+
#### Return
59+
- **Array**: Result of transformation
60+
4861
## License
4962

50-
MIT
51-
[Philipp Alferov](https://github.com/alferov)
63+
MIT © [Philipp Alferov](https://github.com/alferov)

0 commit comments

Comments
 (0)