@nodelib/fs.scandir
List files and directories inside the specified path.
:bulb: Highlights
The package is aimed at obtaining information about entries in the directory.
- :dart: Filter system.
- :gear: Ready for the future development of Node.js (#15699).
Install
$ npm install @nodelib/fs.scandir
Usage
const fsScandir = require('@nodelib/fs.scandir');
fsScandir.scandir('root').then((entries) => {
console.log(entries);
});
API
fsScandir.scandir(path, [options])
Returns a Promise<DirEntry[]>
for provided path.
fsScandir.scandirSync(path, [options])
Returns a DirEntry[]
for provided path.
path
- Type:
string | Buffer | URL
The path to scan.
options
See options section for more detailed information.
Options
stats
- Type:
boolean
- Default:
false
Include information (fs.Stats
) about the file or not.
followSymlinks
- Type:
boolean
- Default:
true
Please, take a look at description inside the fs.stat
package.
throwErrorOnBrokenSymlinks
- Type:
boolean
- Default:
false
Please, take a look at description inside the fs.stat
package.
preFilter
- Type:
Function
((name: string) => boolean
) - Default:
null
Name-based entries filter.
filter
- Type:
Function
((entry: DirEntry) => boolean
) - Default:
null
DirEntry
-based entries filter.
sort
- Type:
Function
((a: DirEntry, b: DirEntry) => number
) - Default:
null
Sort entries on the basis of DirEntry
. Uses the standard sort
method.
DirEntry
interface
Please, take a look at types/entry.ts
file.
Changelog
See the Releases section of our GitHub project for changelogs for each release version.
License
This software is released under the terms of the MIT license.