🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

node-dir

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
n

node-dir

asynchronous file and directory operations for Node.js

0.1.17
latest
100

Supply Chain Security

100

Vulnerability

100

Quality

76

Maintenance

100

License

Version published
Weekly downloads
5M
-16.84%
Maintainers
1
Weekly downloads
 
Created
Issues
24

What is node-dir?

The node-dir package is a utility library for Node.js that provides methods to read directories recursively, read files within directories, and perform other directory and file system related operations. It is useful for applications that need to handle file system operations extensively.

What are node-dir's main functionalities?

Reading all files in a directory recursively

This feature allows you to list all files within a directory and its subdirectories. The function `dir.files` takes a directory path and a callback function that receives an array of file paths.

const dir = require('node-dir');
dir.files('/path/to/dir', function(err, files) {
  if (err) throw err;
  console.log(files);
});

Reading all subdirectories within a directory

This function lists all subdirectories within a specified directory. It is useful for applications that need to analyze or manipulate directory structures.

const dir = require('node-dir');
dir.subdirs('/path/to/dir', function(err, subDirs) {
  if (err) throw err;
  console.log(subDirs);
});

Reading content of files in a directory

This method reads the content of each file in a directory sequentially. It provides the file content to a callback function and proceeds to the next file when the `next` function is called.

const dir = require('node-dir');
dir.readFiles('/path/to/dir', function(err, content, next) {
  if (err) throw err;
  console.log(content);
  next();
});

Other packages similar to node-dir

FAQs

Package last updated on 30 May 2017

Did you know?

Socket

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.

Install

Related posts