
Product
Introducing Webhook Events for Alert Changes
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.
recursive-readdir-async
Advanced tools
Module to recursive read directory async (non blocking). Must be used with Promises. Configurable, extended filtering. etc.
NPM Module to recursive read directory async (non blocking). Returns Promise. Configurable, with callback for extended filtering and progress status. Quiet, NO dependencies. As non blocking module is perfect to be used in any javascript based Desktop applications.
This module uses Promises and can't be used in old javascript engines.
For normal usage into a project, you must install as a NPM dependency. The next command will do all the work:
npm install --save recursive-readdir-async
After install, you can use the module using the require key:
// Assign recursive-readdir-async to constant
const rra = require('recursive-readdir-async')
// use it
Example of basic usage:
const rra = require('recursive-readdir-async');
const list = await rra.list('.');
console.log(list)
const rra = require('recursive-readdir-async');
rra.list('.');
rra.then(function(list){
console.log(list)
})
Example with full features:
const rra = require('recursive-readdir-async');
const options = {
mode: rra.LIST,
recursive: true,
stats: false,
ignoreFolders: true
}
const list = await rra.list('.', options, function (obj, index, total) {
console.log(`${index} of ${total} ${obj.path}`)
if(obj.name=="folder2")
return true;// return true to delete item
})
if(list.error)
console.error(list.error)
else
console.log(list)
An options object can be passed to configure the module. The next options can be used:
The function will return an object and never throw an error. All errors will be added to the returned object. The return object in LIST mode are like this:
[
{
"name":"item_name",
"path":"/absolute/path/to/item",
"fullname":"/absolute/path/to/item/item_name",
"isDirectory": true,
"stats":{
}
},
{
"name":"file.txt",
"path":"/absolute/path/to/item/item_name",
"fullname":"/absolute/path/to/item/item_name/file.txt",
"isDirectory": false,
"stats":{
}
}
]
The same example as TREE:
[
{
"name":"item_name",
"path":"/absolute/path/to/item",
"fullname":"/absolute/path/to/item/item_name",
"isDirectory": true,
"stats":{
},
"contents": [
{
"name":"file.txt",
"path":"/absolute/path/to/item/item_name",
"fullname":"/absolute/path/to/item/item_name/file.txt",
"isDirectory": false,
"stats":{
}
}
]
}
]
isDirectory only exists if stats, recursive or ignoreFolders are true or mode are TREE
stats only exists if stats is true
All errors will be added to the returned object. If error occurs on the main call, the error will be returned like this:
{
"error":
{
"message": "ENOENT: no such file or directory, scandir '/inexistentpath'",
"errno": -4058,
"code": "ENOENT",
"syscall": "scandir",
"path": "/inexistentpath"
},
"path":"/inexistentpath"
}
For errors with files and folders, the error will be added to the item like this:
[
{
"name":"item_name",
"path":"/absolute/path/to/item",
"fullname":"/absolute/path/to/item/item_name",
"error":{
}
}
{
"name":"file.txt",
"path":"/absolute/path/to/item",
"fullname":"/absolute/path/to/item/file.txt",
"error":{
}
}
]
FAQs
Module to recursive read directory async (non blocking). Must be used with Promises. Configurable, extended filtering. etc.
The npm package recursive-readdir-async receives a total of 6,927 weekly downloads. As such, recursive-readdir-async popularity was classified as popular.
We found that recursive-readdir-async 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.

Product
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.

Security News
ENISA has become a CVE Program Root, giving the EU a central authority for coordinating vulnerability reporting, disclosure, and cross-border response.

Product
Socket now scans OpenVSX extensions, giving teams early detection of risky behaviors, hidden capabilities, and supply chain threats in developer tools.