tree-flatter
Advanced tools
Comparing version 1.0.1 to 1.0.2
12
index.js
'use strict'; | ||
const _ = require('lodash'); | ||
/** | ||
@@ -61,2 +63,4 @@ * Recursive node | ||
const stack = []; | ||
console.log(tree); | ||
const _tree = _.cloneDeep(tree); | ||
const settings = { | ||
@@ -71,8 +75,8 @@ initNode: options.initNode || (node => node), | ||
if (Array.isArray(tree) && tree.length) { | ||
if (Array.isArray(_tree) && _tree.length) { | ||
// Object Array | ||
for (let i = 0, len = tree.length; i < len; i++) { | ||
for (let i = 0, len = _tree.length; i < len; i++) { | ||
stack.push( | ||
flattenNodeGenerator( | ||
tree[i], | ||
_tree[i], | ||
'root', // placeholder | ||
@@ -87,3 +91,3 @@ i, | ||
// One object tree | ||
stack.push(flattenNodeGenerator(tree, 'root', 0, settings, stack)); | ||
stack.push(flattenNodeGenerator(_tree, 'root', 0, settings, stack)); | ||
} | ||
@@ -90,0 +94,0 @@ |
{ | ||
"name": "tree-flatter", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Transforms a nested tree structure into a flat list, each item has it's children reference and parent reference.", | ||
@@ -27,3 +27,6 @@ "main": "index.js", | ||
"mocha": "^3.4.2" | ||
}, | ||
"dependencies": { | ||
"lodash": "^4.17.4" | ||
} | ||
} |
@@ -76,3 +76,3 @@ 'use strict'; | ||
for (i = 0; i < 10000; i++) { | ||
for (i = 0; i < 100; i++) { | ||
node = generateChildren(node); | ||
@@ -79,0 +79,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
17363
11
212
1
+ Addedlodash@^4.17.4
+ Addedlodash@4.17.21(transitive)