Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dir-tree-creator

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dir-tree-creator - npm Package Compare versions

Comparing version 1.0.0 to 1.0.2

26

dirTree.js

@@ -7,3 +7,2 @@ (function() {

function add_dir_to_tree(tree, parent_dir_to_find, dir_to_add) {
var i;
if (parent_dir_to_find === tree.label) {

@@ -15,12 +14,12 @@ tree.nodes.push({

} else {
for (i = 0; i < tree.nodes.length; i += 1) {
if (typeof tree.nodes[i] === 'object' && tree.nodes[i].label === parent_dir_to_find) {
tree.nodes[i].nodes.push({
tree.nodes.forEach(function(t_node) {
if (typeof t_node === 'object' && t_node.label === parent_dir_to_find) {
t_node.nodes.push({
label: dir_to_add,
nodes: []
});
} else if (typeof tree.nodes[i] === 'object' && tree.nodes[i].label !== parent_dir_to_find) {
add_dir_to_tree(tree.nodes[i], parent_dir_to_find, dir_to_add);
} else if (typeof t_node === 'object' && t_node.label !== parent_dir_to_find) {
add_dir_to_tree(t_node, parent_dir_to_find, dir_to_add);
}
}
});
}

@@ -30,13 +29,12 @@ }

function add_file_to_tree(tree, parent_dir_to_find, file_to_add) {
var i;
if (parent_dir_to_find === tree.label) {
tree.nodes.push(file_to_add);
} else {
for (i = 0; i < tree.nodes.length; i += 1) {
if (typeof tree.nodes[i] === 'object' && tree.nodes[i].label === parent_dir_to_find) {
tree.nodes[i].nodes.push(file_to_add);
} else if (typeof tree.nodes[i] === 'object' && tree.nodes[i].label !== parent_dir_to_find) {
add_file_to_tree(tree.nodes[i], parent_dir_to_find, file_to_add);
tree.nodes.forEach(function(t_node) {
if (typeof t_node === 'object' && t_node.label === parent_dir_to_find) {
t_node.nodes.push(file_to_add);
} else if (typeof t_node === 'object' && t_node.label !== parent_dir_to_find) {
add_file_to_tree(t_node, parent_dir_to_find, file_to_add);
}
}
});
}

@@ -43,0 +41,0 @@ }

{
"name": "dir-tree-creator",
"version": "1.0.0",
"version": "1.0.2",
"description": "simple directory tree structure creator based on the given root path",

@@ -5,0 +5,0 @@ "main": "dirTree.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc