npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

browse-directory

v0.0.3

Published

For Browsing directory recursively

Downloads

15

Readme

browse-directory

NodeJS Module for browsing directories recursively.

NPM version

Installation

npm install browse-directory

How to use

Run the app

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

How to exploit the 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

Get Files inside a Directory
var dirFiles = browseDir.browseFiles("directory");

console.log(dirFiles);

Get all files of folder "directory"

Get Folders inside a Directory
var dirDirs = browseDir.browseDirs("directory");

console.log(dirDirs);

Get all directories of folder "directory"

The Tree Result

This is the first browsing result, which contain all the files and directories containing in the root directory.

Using browse function

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.

Using browseFiles or browseDirs functions

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.

Tree detailed presentation

It is a simple browse of The tree result, presented previously !.

Complete example

	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"}]

License

MIT

Enjoy it !