You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

simple-tree-utils

Package Overview
Dependencies
Maintainers
0
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-tree-utils - npm Package Compare versions

Comparing version

to
2.2.0

vitest.config.ts

@@ -5,4 +5,10 @@ ### Changelog

#### [2.2.0](https://github.com/Raiper34/simple-tree-utils/compare/2.1.0...2.2.0)
- feat(method): add method now supports adding multiple items at once [`d4f4d5d`](https://github.com/Raiper34/simple-tree-utils/commit/d4f4d5dc4ed6d7e36fbc8d3cca3e106b1b9e453e)
#### [2.1.0](https://github.com/Raiper34/simple-tree-utils/compare/2.0.0...2.1.0)
> 8 January 2025
- feat(list2tree): add ability to define custom tree roots [`#17`](https://github.com/Raiper34/simple-tree-utils/issues/17)

@@ -9,0 +15,0 @@ - docs(changelog): add changelog to project [`2bc7738`](https://github.com/Raiper34/simple-tree-utils/commit/2bc7738a31bcad8617e80267e4c619385d26f885)

9

dist/browser-bundle.js

@@ -142,6 +142,7 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.treeUtils = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){

* @param childData - data of new node
* @param anotherChildData - data of new additional nodes
*/
add(tree, parentId, childData) {
add(tree, parentId, childData, ...anotherChildData) {
if (parentId == null) {
tree.push(childData);
tree.push(childData, ...anotherChildData);
return;

@@ -151,6 +152,6 @@ }

if (index != -1) {
tree[index][this.childrenProp].push(Object.assign({ [this.childrenProp]: [] }, childData));
tree[index][this.childrenProp].push(Object.assign({ [this.childrenProp]: [] }, childData), ...anotherChildData.map(item => (Object.assign({ [this.childrenProp]: [] }, item))));
return;
}
tree.forEach(item => this.add(item[this.childrenProp], parentId, childData));
tree.forEach(item => this.add(item[this.childrenProp], parentId, childData, ...anotherChildData));
}

@@ -157,0 +158,0 @@ /**

@@ -1,1 +0,1 @@

(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.treeUtils=f()}})(function(){var define,module,exports;return function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r}()({1:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.TreeUtils=void 0;var simple_tree_utils_1=require("./simple-tree-utils");Object.defineProperty(exports,"TreeUtils",{enumerable:true,get:function(){return simple_tree_utils_1.TreeUtils}})},{"./simple-tree-utils":2}],2:[function(require,module,exports){"use strict";var __rest=this&&this.__rest||function(s,e){var t={};for(var p in s)if(Object.prototype.hasOwnProperty.call(s,p)&&e.indexOf(p)<0)t[p]=s[p];if(s!=null&&typeof Object.getOwnPropertySymbols==="function")for(var i=0,p=Object.getOwnPropertySymbols(s);i<p.length;i++){if(e.indexOf(p[i])<0&&Object.prototype.propertyIsEnumerable.call(s,p[i]))t[p[i]]=s[p[i]]}return t};Object.defineProperty(exports,"__esModule",{value:true});exports.TreeUtils=void 0;const DEFAULT_ID_PROP="id";const DEFAULT_PARENT_ID_PROP="parentId";const DEFAULT_CHILDREN_PROP="children";class TreeUtils{constructor(config){this.idProp=(config===null||config===void 0?void 0:config.idProp)||DEFAULT_ID_PROP;this.parentIdProp=(config===null||config===void 0?void 0:config.parentIdProp)||DEFAULT_PARENT_ID_PROP;this.childrenProp=(config===null||config===void 0?void 0:config.childrenProp)||DEFAULT_CHILDREN_PROP}list2Tree(list,rootParentId=null){return list.filter(item=>item[this.parentIdProp]===rootParentId).map(item=>Object.assign(Object.assign({},item),{[this.childrenProp]:this.list2Tree(list,item[this.idProp])}))}tree2List(tree){return this._tree2List(TreeUtils.deepCopy(tree))}_tree2List(tree,parentId=null){return TreeUtils.deepCopy(tree).reduce((acc,curr)=>{const _a=curr,_b=this.childrenProp,children=_a[_b],rest=__rest(_a,[typeof _b==="symbol"?_b:_b+""]);return[...acc,Object.assign(Object.assign({},rest),{[this.parentIdProp]:parentId}),...children.length?this._tree2List(children,rest[this.idProp]):[]]},[])}get(tree,id){return this.find(tree,item=>item[this.idProp]===id)}find(tree,fn){const node=tree.find(item=>fn(item));if(node){return node}return tree.reduce((acc,curr)=>acc||this.find(curr[this.childrenProp]||[],fn),null)}filter(tree,fn){const nodes=tree.filter(item=>fn(item));return tree.reduce((acc,curr)=>[...acc,...curr[this.childrenProp].length?this.filter(curr[this.childrenProp],fn):[]],nodes)}delete(tree,id){const index=tree.findIndex(item=>item[this.idProp]==id);if(index!=-1){return tree.splice(index,1)[0]}return tree.reduce((acc,curr)=>acc||this.delete(curr[this.childrenProp],id),null)}add(tree,parentId,childData){if(parentId==null){tree.push(childData);return}const index=tree.findIndex(item=>item[this.idProp]==parentId);if(index!=-1){tree[index][this.childrenProp].push(Object.assign({[this.childrenProp]:[]},childData));return}tree.forEach(item=>this.add(item[this.childrenProp],parentId,childData))}edit(tree,id,data){const index=tree.findIndex(item=>item[this.idProp]==id);if(index!=-1){tree[index]=Object.assign({[this.idProp]:tree[index][this.idProp],[this.childrenProp]:[]},data);return}tree.forEach(item=>this.edit(item[this.childrenProp],id,data))}getDescendants(tree,id){const node=this.get(tree,id);return node?this._getDescendants(node):[]}_getDescendants(node){return[...node[this.childrenProp],...node[this.childrenProp].reduce((acc,curr)=>[...acc,...this._getDescendants(curr)],[])]}getAncestors(tree,id){const parents=[];let parent=this.getParent(tree,id);while(parent){parents.push(parent);parent=this.getParent(tree,parent[this.idProp])}return parents.reverse()}getPathNodes(tree,id){return this.getAncestors(tree,id)}getParent(tree,id){return this._getParent(tree,id)}_getParent(tree,id,parent=null){const node=tree.find(item=>item[this.idProp]===id);if(node){return parent}return tree.reduce((acc,curr)=>acc||this._getParent(curr[this.childrenProp]||[],id,curr),null)}getChildren(tree,id){var _a;return((_a=this.get(tree,id))===null||_a===void 0?void 0:_a[this.childrenProp])||[]}getNeighbours(tree,id){return[this.getParent(tree,id),...this.getChildren(tree,id)].filter(item=>item)}getSiblings(tree,id){var _a;return(((_a=this.getParent(tree,id))===null||_a===void 0?void 0:_a[this.childrenProp])||[]).filter(item=>item[this.idProp]!==id)}getLeafs(tree,id){return this.filter(this.getSubTree(tree,id),item=>!item[this.childrenProp].length)}getSubTree(tree,id){return this.getChildren(tree,id)}getSize(tree,id){return this.tree2List(this.getSubTree(tree,id)).length+1}getBreath(tree,id){return this.getLeafs(tree,id).length}getDepth(tree,id){return this.getPathNodes(tree,id).length}getLevel(tree,id){return this.getDepth(tree,id)+1}getDegree(tree,id){return this.getChildren(tree,id).length}getTreeDegree(tree){return tree.reduce((acc,curr)=>Math.max(acc,curr[this.childrenProp].length,this.getTreeDegree(curr[this.childrenProp])),0)}getNodesAtLevel(tree,level){return this._getNodesAtLevel(tree,level)}_getNodesAtLevel(tree,level,actualLevel=0){return tree.reduce((acc,curr)=>[...acc,...level===actualLevel?[curr]:[],...actualLevel<level?this._getNodesAtLevel(curr[this.childrenProp],level,actualLevel+1):[]],[])}getWidth(tree,level){return this.getNodesAtLevel(tree,level).length}getHeight(tree,id){return this.getHeightNode(this.getSubTree(tree,id))}getHeightNode(tree,height=0){return tree.reduce((acc,curr)=>Math.max(acc,this.getHeightNode(curr[this.childrenProp],height+1)),height)}getDistance(tree,id1,id2){const ancestors1=[...this.getPathNodes(tree,id1),this.get(tree,id1)];const ancestors2=[...this.getPathNodes(tree,id2),this.get(tree,id2)];const common=[...ancestors1].reverse().find(element=>ancestors2.includes(element));if(!common){return-1}const commonIndex1=ancestors1.findIndex(item=>item.id===common.id);const commonIndex2=ancestors2.findIndex(item=>item.id===common.id);return ancestors1.length-commonIndex1-1+(ancestors2.length-commonIndex2-1)}static deepCopy(obj){return JSON.parse(JSON.stringify(obj))}}exports.TreeUtils=TreeUtils},{}]},{},[1])(1)});
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.treeUtils=f()}})(function(){var define,module,exports;return function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r}()({1:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.TreeUtils=void 0;var simple_tree_utils_1=require("./simple-tree-utils");Object.defineProperty(exports,"TreeUtils",{enumerable:true,get:function(){return simple_tree_utils_1.TreeUtils}})},{"./simple-tree-utils":2}],2:[function(require,module,exports){"use strict";var __rest=this&&this.__rest||function(s,e){var t={};for(var p in s)if(Object.prototype.hasOwnProperty.call(s,p)&&e.indexOf(p)<0)t[p]=s[p];if(s!=null&&typeof Object.getOwnPropertySymbols==="function")for(var i=0,p=Object.getOwnPropertySymbols(s);i<p.length;i++){if(e.indexOf(p[i])<0&&Object.prototype.propertyIsEnumerable.call(s,p[i]))t[p[i]]=s[p[i]]}return t};Object.defineProperty(exports,"__esModule",{value:true});exports.TreeUtils=void 0;const DEFAULT_ID_PROP="id";const DEFAULT_PARENT_ID_PROP="parentId";const DEFAULT_CHILDREN_PROP="children";class TreeUtils{constructor(config){this.idProp=(config===null||config===void 0?void 0:config.idProp)||DEFAULT_ID_PROP;this.parentIdProp=(config===null||config===void 0?void 0:config.parentIdProp)||DEFAULT_PARENT_ID_PROP;this.childrenProp=(config===null||config===void 0?void 0:config.childrenProp)||DEFAULT_CHILDREN_PROP}list2Tree(list,rootParentId=null){return list.filter(item=>item[this.parentIdProp]===rootParentId).map(item=>Object.assign(Object.assign({},item),{[this.childrenProp]:this.list2Tree(list,item[this.idProp])}))}tree2List(tree){return this._tree2List(TreeUtils.deepCopy(tree))}_tree2List(tree,parentId=null){return TreeUtils.deepCopy(tree).reduce((acc,curr)=>{const _a=curr,_b=this.childrenProp,children=_a[_b],rest=__rest(_a,[typeof _b==="symbol"?_b:_b+""]);return[...acc,Object.assign(Object.assign({},rest),{[this.parentIdProp]:parentId}),...children.length?this._tree2List(children,rest[this.idProp]):[]]},[])}get(tree,id){return this.find(tree,item=>item[this.idProp]===id)}find(tree,fn){const node=tree.find(item=>fn(item));if(node){return node}return tree.reduce((acc,curr)=>acc||this.find(curr[this.childrenProp]||[],fn),null)}filter(tree,fn){const nodes=tree.filter(item=>fn(item));return tree.reduce((acc,curr)=>[...acc,...curr[this.childrenProp].length?this.filter(curr[this.childrenProp],fn):[]],nodes)}delete(tree,id){const index=tree.findIndex(item=>item[this.idProp]==id);if(index!=-1){return tree.splice(index,1)[0]}return tree.reduce((acc,curr)=>acc||this.delete(curr[this.childrenProp],id),null)}add(tree,parentId,childData,...anotherChildData){if(parentId==null){tree.push(childData,...anotherChildData);return}const index=tree.findIndex(item=>item[this.idProp]==parentId);if(index!=-1){tree[index][this.childrenProp].push(Object.assign({[this.childrenProp]:[]},childData),...anotherChildData.map(item=>Object.assign({[this.childrenProp]:[]},item)));return}tree.forEach(item=>this.add(item[this.childrenProp],parentId,childData,...anotherChildData))}edit(tree,id,data){const index=tree.findIndex(item=>item[this.idProp]==id);if(index!=-1){tree[index]=Object.assign({[this.idProp]:tree[index][this.idProp],[this.childrenProp]:[]},data);return}tree.forEach(item=>this.edit(item[this.childrenProp],id,data))}getDescendants(tree,id){const node=this.get(tree,id);return node?this._getDescendants(node):[]}_getDescendants(node){return[...node[this.childrenProp],...node[this.childrenProp].reduce((acc,curr)=>[...acc,...this._getDescendants(curr)],[])]}getAncestors(tree,id){const parents=[];let parent=this.getParent(tree,id);while(parent){parents.push(parent);parent=this.getParent(tree,parent[this.idProp])}return parents.reverse()}getPathNodes(tree,id){return this.getAncestors(tree,id)}getParent(tree,id){return this._getParent(tree,id)}_getParent(tree,id,parent=null){const node=tree.find(item=>item[this.idProp]===id);if(node){return parent}return tree.reduce((acc,curr)=>acc||this._getParent(curr[this.childrenProp]||[],id,curr),null)}getChildren(tree,id){var _a;return((_a=this.get(tree,id))===null||_a===void 0?void 0:_a[this.childrenProp])||[]}getNeighbours(tree,id){return[this.getParent(tree,id),...this.getChildren(tree,id)].filter(item=>item)}getSiblings(tree,id){var _a;return(((_a=this.getParent(tree,id))===null||_a===void 0?void 0:_a[this.childrenProp])||[]).filter(item=>item[this.idProp]!==id)}getLeafs(tree,id){return this.filter(this.getSubTree(tree,id),item=>!item[this.childrenProp].length)}getSubTree(tree,id){return this.getChildren(tree,id)}getSize(tree,id){return this.tree2List(this.getSubTree(tree,id)).length+1}getBreath(tree,id){return this.getLeafs(tree,id).length}getDepth(tree,id){return this.getPathNodes(tree,id).length}getLevel(tree,id){return this.getDepth(tree,id)+1}getDegree(tree,id){return this.getChildren(tree,id).length}getTreeDegree(tree){return tree.reduce((acc,curr)=>Math.max(acc,curr[this.childrenProp].length,this.getTreeDegree(curr[this.childrenProp])),0)}getNodesAtLevel(tree,level){return this._getNodesAtLevel(tree,level)}_getNodesAtLevel(tree,level,actualLevel=0){return tree.reduce((acc,curr)=>[...acc,...level===actualLevel?[curr]:[],...actualLevel<level?this._getNodesAtLevel(curr[this.childrenProp],level,actualLevel+1):[]],[])}getWidth(tree,level){return this.getNodesAtLevel(tree,level).length}getHeight(tree,id){return this.getHeightNode(this.getSubTree(tree,id))}getHeightNode(tree,height=0){return tree.reduce((acc,curr)=>Math.max(acc,this.getHeightNode(curr[this.childrenProp],height+1)),height)}getDistance(tree,id1,id2){const ancestors1=[...this.getPathNodes(tree,id1),this.get(tree,id1)];const ancestors2=[...this.getPathNodes(tree,id2),this.get(tree,id2)];const common=[...ancestors1].reverse().find(element=>ancestors2.includes(element));if(!common){return-1}const commonIndex1=ancestors1.findIndex(item=>item.id===common.id);const commonIndex2=ancestors2.findIndex(item=>item.id===common.id);return ancestors1.length-commonIndex1-1+(ancestors2.length-commonIndex2-1)}static deepCopy(obj){return JSON.parse(JSON.stringify(obj))}}exports.TreeUtils=TreeUtils},{}]},{},[1])(1)});

@@ -100,4 +100,5 @@ /**

* @param childData - data of new node
* @param anotherChildData - data of new additional nodes
*/
add(tree: any[], parentId: any, childData: any): void;
add(tree: any[], parentId: any, childData: any, ...anotherChildData: any[]): void;
/**

@@ -104,0 +105,0 @@ * Method to update node by id with given data in tree (mutable operation!)

@@ -134,6 +134,7 @@ "use strict";

* @param childData - data of new node
* @param anotherChildData - data of new additional nodes
*/
add(tree, parentId, childData) {
add(tree, parentId, childData, ...anotherChildData) {
if (parentId == null) {
tree.push(childData);
tree.push(childData, ...anotherChildData);
return;

@@ -143,6 +144,6 @@ }

if (index != -1) {
tree[index][this.childrenProp].push(Object.assign({ [this.childrenProp]: [] }, childData));
tree[index][this.childrenProp].push(Object.assign({ [this.childrenProp]: [] }, childData), ...anotherChildData.map(item => (Object.assign({ [this.childrenProp]: [] }, item))));
return;
}
tree.forEach(item => this.add(item[this.childrenProp], parentId, childData));
tree.forEach(item => this.add(item[this.childrenProp], parentId, childData, ...anotherChildData));
}

@@ -149,0 +150,0 @@ /**

{
"name": "simple-tree-utils",
"version": "2.1.0",
"version": "2.2.0",
"description": "Simple Tree Utils is the library to convert and manipulate with tree-like structures.",

@@ -20,3 +20,4 @@ "keywords": [

"start": "npm run build && node dist/main.js",
"test": "nyc -r lcov jasmine-ts --config=jasmine.json",
"test": "vitest run --coverage",
"test:dev": "vitest --ui --coverage",
"test:ci": "npm run test && cat ./coverage/lcov.info | coveralls",

@@ -37,3 +38,4 @@ "lint": "eslint ./src",

"@types/eslint__js": "^8.42.3",
"@types/jasmine": "^3.6.6",
"@vitest/coverage-v8": "^3.0.2",
"@vitest/ui": "^3.0.2",
"auto-changelog": "^2.5.0",

@@ -46,13 +48,10 @@ "browserify": "^17.0.1",

"husky": "^9.1.7",
"jasmine": "^3.6.4",
"jasmine-ts": "^0.4.0",
"netlify-cli": "^17.37.0",
"nyc": "^17.1.0",
"release-it": "^17.11.0",
"ts-node": "^10.9.2",
"typedoc": "^0.26.9",
"typescript": "^5.6.0",
"typescript-eslint": "^8.8.1",
"uglify-js": "^3.19.3"
"uglify-js": "^3.19.3",
"vitest": "^3.0.2"
}
}

@@ -169,6 +169,7 @@ /* eslint-disable @typescript-eslint/no-explicit-any */

* @param childData - data of new node
* @param anotherChildData - data of new additional nodes
*/
add(tree: any[], parentId: any, childData: any): void {
add(tree: any[], parentId: any, childData: any, ...anotherChildData: any[]): void {
if (parentId == null) {
tree.push(childData);
tree.push(childData, ...anotherChildData);
return;

@@ -178,6 +179,9 @@ }

if (index != -1) {
tree[index][this.childrenProp].push({[this.childrenProp]: [], ...childData});
tree[index][this.childrenProp].push(
{[this.childrenProp]: [], ...childData},
...anotherChildData.map(item => ({[this.childrenProp]: [], ...item}))
);
return;
}
tree.forEach(item => this.add(item[this.childrenProp], parentId, childData));
tree.forEach(item => this.add(item[this.childrenProp], parentId, childData, ...anotherChildData));
}

@@ -184,0 +188,0 @@

@@ -0,1 +1,2 @@

import {beforeEach, describe, expect, it} from 'vitest'
import {TreeUtils} from "../src";

@@ -138,2 +139,30 @@

it('should add multiple nodes to parent with given customId', () => {
treeUtils.add(mock, 4,
{customId: 7, parentCustomId: 4, name: 'Node 7', customChildren: []},
{customId: 8, parentCustomId: 4, name: 'Node 8', customChildren: []},
);
const out = [
{
customId: 1, parentCustomId: null, name: 'Node 1', customChildren: [
{
customId: 3, parentCustomId: 1, name: 'Node 3', customChildren: [
{customId: 6, parentCustomId: 3, name: 'Node 6', customChildren: []}
]
},
{customId: 4, parentCustomId: 1, name: 'Node 4', customChildren: [
{customId: 7, parentCustomId: 4, name: 'Node 7', customChildren: []},
{customId: 8, parentCustomId: 4, name: 'Node 8', customChildren: []},
]},
]
},
{
customId: 2, parentCustomId: null, name: 'Node 2', customChildren: [
{customId: 5, parentCustomId: 2, name: 'Node 5', customChildren: []},
]
},
]
expect(mock).toEqual(out);
});
it('should add node to root', () => {

@@ -162,2 +191,29 @@ treeUtils.add(mock, null, {customId: 7, parentCustomId: 4, name: 'Node 7', customChildren: []});

it('should add multiple nodes to root', () => {
treeUtils.add(mock, null,
{customId: 7, parentCustomId: 4, name: 'Node 7', customChildren: []},
{customId: 8, parentCustomId: 4, name: 'Node 8', customChildren: []},
);
const out = [
{
customId: 1, parentCustomId: null, name: 'Node 1', customChildren: [
{
customId: 3, parentCustomId: 1, name: 'Node 3', customChildren: [
{customId: 6, parentCustomId: 3, name: 'Node 6', customChildren: []}
]
},
{customId: 4, parentCustomId: 1, name: 'Node 4', customChildren: []},
]
},
{
customId: 2, parentCustomId: null, name: 'Node 2', customChildren: [
{customId: 5, parentCustomId: 2, name: 'Node 5', customChildren: []},
]
},
{customId: 7, parentCustomId: 4, name: 'Node 7', customChildren: []},
{customId: 8, parentCustomId: 4, name: 'Node 8', customChildren: []}
]
expect(mock).toEqual(out);
});
it('should edit node of given customId by given data', () => {

@@ -164,0 +220,0 @@ treeUtils.edit(mock, 5, {customId: 5, parentCustomId: 2, name: 'Node 5 edited', customChildren: []});