Package Exports
- @nodelib/fs.scandir
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@nodelib/fs.scandir) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
@nodelib/fs.scandir
List files and directories inside the specified path.
💡 Highlights
The package is aimed at obtaining information about entries in the directory.
- 🎯 Filter system.
- ⚙️ 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); // => [{ name: 'name', path: 'root/name', ino: 0, is... }]
});
API
fsScandir.scandir(path, [options])
Returns a Promise<DirEntry[]>
for provided path.
fsScandir.scandirSync(path, [options])
Returns a DirEntry[]
for provided path.
fsScandir.scandirCallback(path, [options], callback)
Returns a DirEntry[]
for provided path with standard callback-style.
path
- Type:
string | Buffer | URL
The path to scan.
options
- Type:
Object
See options section for more detailed information.
Options
includeRootDirectory
- Type:
boolean
- Default:
false
Include root directory to result array of DirEntry
items.
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, path: string) => boolean
) - Default:
null
Name- and Path-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.
fs
- Type:
FileSystemAdapter
- Default:
built-in FS methods
By default, the built-in Node.js module (fs
) is used to work with the file system. You can replace each method with your own.
interface FileSystemAdapter {
lstat?: typeof fs.lstat,
stat?: typeof fs.stat,
lstatSync?: typeof fs.lstatSync,
statSync?: typeof fs.statSync,
readdir?: typeof fs.readdir,
readdirSync?: typeof fs.readdirSync
}
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.