nx.js
NamespacesSwitchFunctions

readDir

readDir(path): AsyncIterable<DirEntry>

Returns an AsyncIterable that yields DirEntry objects for each entry within path, one at a time. The directory handle is automatically closed when iteration completes or the loop is exited early.

Parameters

ParameterTypeDescription
pathPathLikePath of the directory to read.

Returns

AsyncIterable<DirEntry>

Examples

for await (const entry of Switch.readDir('sdmc:/')) {
  console.log(entry.name, entry.isFile ? 'file' : 'dir');
}

To collect all entries into an array:

const entries = await Array.fromAsync(Switch.readDir('sdmc:/'));

On this page