Skip to content

Commit 802fc63

Browse files
author
Philipp Alferov
committed
Add inline documentation
1 parent 29cd16f commit 802fc63

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

index.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,23 @@ function orderByParents(list, config) {
3535
return parents;
3636
}
3737

38-
module.exports = function(options) {
38+
/**
39+
* arrayToTree
40+
* Convert a plain array of nodes (with pointers to parent nodes) to a tree
41+
*
42+
* @name arrayToTree
43+
* @function
44+
* @param {Object} options An object containing the following fields:
45+
*
46+
* - `parentProperty` (String): A name of a property where a link to
47+
* a parent node could be found. Default: 'parent_id'
48+
* - `data` (Array): An array with data
49+
* - `customID` (String): An unique node identifier. Default: 'id'
50+
*
51+
* @return {Array} Result of transformation
52+
*/
53+
54+
module.exports = function arrayToTree(options) {
3955
var config = util._extend({
4056
parentProperty: 'parent_id',
4157
data: [],

0 commit comments

Comments
 (0)