Security News
cURL Project and Go Security Teams Reject CVSS as Broken
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
fs-readdir-rec-gen
Advanced tools
Get an ES6 generator for files in a directory and subdirectories
A NodeJS module to get a generator for files in a directory and subdirectories, with a file filter capability.
npm install --save fs-readdir-rec-gen
fsReadDirRecGen(dir [, options] [, filter] [, recursive=true])
dir
{String} - the directory where to look for files.options
{String|Object} - optional, options passed NodeJs File System API (see NodeJS' fs API).filter
{Function} - optional, a function to filter on file names. Defaults to no filter.recursive
{Boolean} - optional, whether to search in sub directories. Defaults to true.If dir
does not exists, an exception is immediately thrown by NodeJS' fs
API.
With a simple .js file filter:
var fsReadDirRecGen = require('fs-readdir-rec-gen')
function dotJsFilesFilter(fileName) {
return fileName.endsWith('.js');
};
for (let file of fsReadDirRecGen('./test/testData', dotJsFilesFilter)) {
console.log('Relative path to file : ' + file);
}
Relative path to file : test/testData/aa/class3.js
Relative path to file : test/testData/abstractsuperclass.js
Relative path to file : test/testData/class.js
Relative path to file : test/testData/class2.js
With a RegExp file filter:
var fsReadDirRecGen = require('fs-readdir-rec-gen')
function classdotJsFileFilter() {
var format = RegExp(/.*class.*\.js/i);
return function (filename) {
return format.test(filename);
}
};
for (let file of fsReadDirRecGen('./test/testData', classdotJsFileFilter())){
console.log('Relative path to file : ' + file);
}
Without file filter:
var fsReadDirRecGen = require('fs-readdir-rec-gen')
for (let file of fsReadDirRecGen('./test/testData')){
console.log('Relative path to file : ' + file);
}
More examples in examples.js and test dir.
FAQs
Get an ES6 generator for files in a directory and subdirectories
We found that fs-readdir-rec-gen 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.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.