Skip to content

@jsvision/files / scanDirectory

Function: scanDirectory() ​

scanDirectory(fs, dirPath, opts?): DirEntry[]

Defined in: files/src/fs/scan.ts:69

Scan one directory through a filesystem and return the sorted, filtered listing model.

Throws if the directory itself cannot be read — callers turn that into an error box. A failure on a single entry is skipped by the filesystem's readDir, so the result is never partial or garbage.

Parameters ​

fs ​

FileSystem

The filesystem to read through.

dirPath ​

string

The directory to scan.

opts? ​

ScanOptions = {}

Wildcard, hidden-file, and extra-filter options.

Returns ​

DirEntry[]

The sorted entries (files, then directories, then ..).

Example ​

ts
import { scanDirectory, nodeFileSystem } from '@jsvision/files';

const entries = scanDirectory(nodeFileSystem, '/home/user', { wildcard: '*.ts' });
for (const e of entries) console.log(e.kind, e.name);