Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
fs-readdir-recursive
Advanced tools
The fs-readdir-recursive npm package is a utility for reading directories recursively. It allows you to list all files within a directory and its subdirectories, making it useful for tasks that require directory traversal.
Read all files in a directory recursively
This feature allows you to read all files in a specified directory and its subdirectories. The code sample demonstrates how to use the package to list all files within 'path/to/directory'.
const read = require('fs-readdir-recursive');
const files = read('path/to/directory');
console.log(files);
Filter files based on a condition
This feature allows you to filter the files based on a condition. The code sample demonstrates how to list only JavaScript files within 'path/to/directory' and its subdirectories.
const read = require('fs-readdir-recursive');
const files = read('path/to/directory', (name) => name.endsWith('.js'));
console.log(files);
The recursive-readdir package provides similar functionality to fs-readdir-recursive, allowing you to read directories recursively. It also supports filtering files based on conditions and excluding specific files or directories.
The klaw package is another alternative for recursive directory traversal. It provides a stream-based API for reading directories and supports filtering and excluding files or directories. It is more flexible and powerful compared to fs-readdir-recursive.
The readdirp package offers recursive directory reading with additional features like filtering, streaming, and handling large directories efficiently. It is more feature-rich and performant compared to fs-readdir-recursive.
Read a directory recursively.
npm install fs-readdir-recursive
var read = require('fs-readdir-recursive')
read(__dirname) === [
'test/test.js',
'index.js',
'LICENSE',
'package.json',
'README.md'
]
root
is the directory you wish to scan. filter
is an optional filter for the files with three params(name, index, dir). By default, filter is:
function (name) {
return name[0] !== '.'
}
Which basically just ignores .
files.
FAQs
Recursively read a directory
We found that fs-readdir-recursive demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 open source maintainers 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
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.