readdirp
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
graceful-fs | 2.0.3 | 4.9 kB | BSD | prod | 2 1 |
minimatch | 0.2.14 | 17.17 kB | MIT | prod | 3 |
readable-stream | 1.0.34 | 15.08 kB | MIT | prod |
readdirp
is a recursive version of fs.readdir
, popular in the npm package ecosystem, which exposes both a streaming API and a promise API.
To use readdirp
, you first need to install it via npm using the command npm install readdirp
. Once installed, you can require it in your code with const readdirp = require('readdirp');
.
There are several ways to use readdirp
depending on your specific needs:
readdirp
with streams and for-await
:for await (const entry of readdirp('.')) {
const {path} = entry;
console.log(`${JSON.stringify({path})}`);
}
readdirp
is through its Promise API, which uses more RAM and CPU than streams / for-await:const files = await readdirp.promise('.');
console.log(files.map(file => file.path));
readdirp('test', {
fileFilter: '*.js',
directoryFilter: ['!.git', '!*modules'],
type: 'files_directories',
depth: 1
});
The above examples demonstrate basic usage for common cases, but readdirp
provides a more complex API for further needs.
The detailed documentation for readdirp
is in the GitHub package repository. Here you can find all details regarding the API and its options. Anything from basic package usage to advanced configurations can be found within these comprehensive docs. Ensure to check out the 'API' and 'options' sections specifically round out your understanding of the functionality offered by readdirp
.