A recursive read dir, generator based implementation
A NodeJS module to get a generator for files in a directory and subdirectories, with a file filter capability.
Install
npm install --save fs-readdir-rec-gen
API
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.
Examples
With a simple .js file filter:
var fsReadDirRecGen = { return fileName;};for let file of console;
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 = { var format = RegExp/.*class.*\.js/i; return { return format; }};for let file of console;
Without file filter:
var fsReadDirRecGen = for let file of console;
More examples in examples.js and test dir.