Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions dist/list-to-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const defaultOptions = {
key_parent: 'parent' ,
key_child: 'child',
empty_children: false,
root_id: 0
};

const depthKeyName = '__depth'
Expand Down Expand Up @@ -39,12 +40,12 @@ module.exports = class LTT{

options = Object.assign({}, defaultOptions, options);
this.options = options;
const { key_id, key_parent } = options;
const { key_id, key_parent , root_id} = options;

writeDepth(key_parent, key_id, _list)
sortBy(_list, depthKeyName, key_parent, key_id);

const tree = new IronTree({ [key_id]: 0 });
const tree = new IronTree({ [key_id]: root_id });
_list.forEach((item, index) => {
tree.add((parentNode) => {
return parentNode.get(key_id) === item[key_parent];
Expand Down