
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
browse-directory
Advanced tools
NodeJS Module for browsing directories recursively.
npm install browse-directory
var browseDir = require("browse-directory");
var tree = browseDir.browse("directory");
Just require the module and call search function with the path name of the search root directory
Then, to run app, you just have to run command :
node index
This will show you a browsing results
You have two part of results : "the Tree Result" and the "Tree detailed presentation" To get the tree detailed presentation of result, do the following :
browseDir.showTree(tree);
By calling the showTree function of browseDir, which take a tree object, returned by the previously used browse function
NB : We can also brow all files or folders inside a search directory
var dirFiles = browseDir.browseFiles("directory");
console.log(dirFiles);
Get all files of folder "directory"
var dirDirs = browseDir.browseDirs("directory");
console.log(dirDirs);
Get all directories of folder "directory"
This is the first browsing result, which contain all the files and directories containing in the root directory.
It is a javascript objet which contain tables with others javascript objects, using key - values. Every directory name is a key of a new javascript object in the root object result. In this case, the first object key is the name of a search directort, and the others are the names of result directories.
So, to browse our collection, we must first browse the first root object and each directory obtained, retrieve its content via the same collection, through its name like key.
It is a table which contain javascript objects, using key - values. Every object of collection represent a directory or file result, with properties like : the type, the name and the relative path.
We just have to browse our collection result to get all the files or directories informations.
It is a simple browse of The tree result, presented previously !.
var browseDir = require("browse-directory");
// Browse folder "directory"
var dirTree = browseDir.browse("directory");
// Show tree
browseDir.showTree(dirTree);
// Get all files of folder "directory"
var dirFiles = browseDir.browseFiles("directory");
console.log(dirFiles);
// Get all directories of folder "directory"
var dirDirs = browseDir.browseDirs("directory");
console.log(dirDirs);
Will Show
Level ==> root
# Contains :
- {"type":"dir","src":"dir1"}
* dir1 ---> [{"type":"dir","src":"dir2"}]
- {"type":"file","src":"file1.txt"}
Level ==> dir1
# Contains :
- {"type":"dir","src":"dir2"}
* dir2 ---> []
Level ==> dir2
# Contains :
Files browsing : [{"type":"file","name":"file1.txt","src":"directory/file1.txt"}]
Directories browsing : [{"type":"dir","name":"dir1","src":"directory/dir1"},{"type":"dir","name":"dir2","src":"directory/dir1/dir2"}]
Enjoy it !
FAQs
For Browsing directory recursively
We found that browse-directory demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.