readdir-on-steroids
Recursively read the contents of a directory.
Installation
npm install readdir-on-steroids
Usage
; const directory = processargv3 || "."; // only list files { return stats;} // don't traverse the .git, lib, node_modules or .vscode directories { return !/\.git$/ && !/lib/ && !/node_modules/ && !/\.vscode/ ;} ;
Output:
.gitignore
README.md
examples/index.ts
package.json
src/__mocks__/fs.ts
src/index.test.ts
src/index.ts
yarn.lock
API
readdirdirectory: string, options?: Options: Promise<string>
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
directory |
string |
✓ | The directory to read. | |
options |
Options |
{} |
The options. |
Options
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
concurrency |
number |
4 | The maximum number of concurrent calls to readdir . |
|
listFilter |
(path: string, stats: Stats) => boolean |
A function filtering the paths that will be returned. | ||
walkFilter |
(path: string, stats: Stats) => boolean |
A function filtering the paths that will be walked. |
Stats
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
root |
string |
✓ | The root directory being read. | |
depth |
number |
✓ | The relative depth from the root directory. |