Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report
Generated on May 3, 2024 via pnpm

node-dir 0.1.17

asynchronous file and directory operations for Node.js
Package summary
Share
0
issues
2
licenses
4
MIT
1
ISC
Package created
25 Sep 2012
Version published
30 May 2017
Maintainers
1
Total deps
5
Direct deps
1
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
4 Packages, Including:
balanced-match@1.0.2
brace-expansion@1.1.11
concat-map@0.0.1
node-dir@0.1.17

ISC License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
Cannot
hold-liable
Must
include-copyright
include-license
1 Packages, Including:
minimatch@3.1.2
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

1
All Dependencies CSV
β“˜ This is a list of node-dir 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities
minimatch3.1.211.66 kBISC
prod

Visualizations

Frequently Asked Questions

What does node-dir do?

Node-dir is a lightweight Node.js module that provides methods for common directory and file operations. It parades a host of functions that support asynchronous and non-blocking methods for trasversing the directory structure. The features of node-dir include recursively getting an array of file paths, subdirectories, both files and subdirectories and methods for recursively, sequentially reading and processing the content of files in a directory and its subdirectories. This package is designed to offer flexibility options where needed and is ideal for handling asynchronous file and directory operations in a Node.js environment.

How do you use node-dir?

To use node-dir in your Node.js application, the first step is to install the module via npm: npm install node-dir. Once installed, you can import node-dir into your JavaScript file: var dir = require('node-dir');

Node-dir provides various methods to handle file and directory operations. Here are a few usage examples:

To read files from a directory, you can use the readFiles method:

var dir = require('node-dir');

dir.readFiles(__dirname,
    function(err, content, next) {
        if (err) throw err;
        console.log('content:', content);
        next();
    },
    function(err, files){
        if (err) throw err;
        console.log('finished reading files:', files);
    }
);

To asynchronously iterate through files and pass an array of file paths to a callback, use the files method:

var dir = require('node-dir');

dir.files(__dirname, function(err, files) {
    if (err) throw err;
    console.log(files);
});

Node-dir also supports synchronous operations using the {sync:true} option. The files method can be used synchronously like so:

var dir = require('node-dir');

var files = dir.files(__dirname, {sync:true});
console.log(files);

Node-dir supports promises as well:

var dir = require('node-dir');

dir.promiseFiles(__dirname)
.then((files)=>{
    console.log(files);
})
.catch(e=>console.error(e))

Where are the node-dir docs?

The documentation for node-dir is found within the readme file on the official GitHub repository. The documentation provides an in-depth look at the API, including usage examples and descriptions of the various methods available. You can dive into it to better understand how each method works and how to explore the full potential of the node-dir package. The table of contents in the readme makes it easier to navigate through the documentation. Each available method such as readFiles, readFilesStream, files, promiseFiles, subdirs, paths has been well documented.