Dir
[<Interface>]
type Dir =
abstract member path: string
abstract member SymbolAsyncDispose () : Promise<unit>
abstract member SymbolAsyncIterator () : AsyncIterator<Dirent<string>,obj,obj>
abstract member SymbolDispose () : unit
abstract member close (cb: NoParamCallback) : unit
abstract member close () : Promise<unit>
abstract member closeSync () : unit
abstract member read (cb: Cb) : unit
abstract member read () : Promise<Dirent<string> option>
abstract member readSync () : Dirent<string> option| Assembly | Xantham.Fable.Node |
A class representing a directory stream.
Created by opendir, opendirSync, or fsPromises.opendir().
import { opendir } from 'node:fs/promises';
try {
const dir = await opendir('./');
for await (const dirent of dir)
console.log(dirent.name);
} catch (err) {
console.error(err);
}
When using the async iterator, the fs.Dir object will be automatically closed after the iterator exits.
@since v12.12.0
Declared inside
Read |
Properties
abstract member path: string
abstract member path: stringThe read-only path of this directory as was provided to opendir,opendirSync, or fsPromises.opendir().
@since v12.12.0
Methods
abstract member SymbolAsyncDispose () : Promise<unit>
abstract member SymbolAsyncDispose () : Promise<unit>Calls dir.close() if the directory handle is open, and returns a promise that fulfills when disposal is complete.
@since v22.17.0
abstract member SymbolAsyncIterator () : AsyncIterator<Dirent<string>,obj,obj>
abstract member SymbolAsyncIterator () : AsyncIterator<Dirent<string>,obj,obj>Asynchronously iterates over the directory via readdir(3) until all entries have been read.
abstract member SymbolDispose () : unit
abstract member SymbolDispose () : unitCalls dir.closeSync() if the directory handle is open, and returns undefined.
@since v22.17.0
abstract member close (cb: NoParamCallback) : unit
abstract member close (cb: NoParamCallback) : unitAsynchronously close the directory's underlying resource handle. Subsequent reads will result in errors.
A promise is returned that will be fulfilled after the resource has been closed.
@since v12.12.0
abstract member close () : Promise<unit>
abstract member close () : Promise<unit>Asynchronously close the directory's underlying resource handle. Subsequent reads will result in errors.
A promise is returned that will be fulfilled after the resource has been closed.
@since v12.12.0
abstract member closeSync () : unit
abstract member closeSync () : unitSynchronously close the directory's underlying resource handle. Subsequent reads will result in errors.
@since v12.12.0
abstract member read (cb: Cb) : unit
abstract member read (cb: Cb) : unitAsynchronously read the next directory entry via readdir(3) as an fs.Dirent.
A promise is returned that will be fulfilled with an fs.Dirent, or null if there are no more directory entries to read.
Directory entries returned by this function are in no particular order as provided by the operating system's underlying directory mechanisms. Entries added or removed while iterating over the directory might not be included in the iteration results.
@since v12.12.0
Returns. containing {fs.Dirent|null}
abstract member read () : Promise<Dirent<string> option>
abstract member read () : Promise<Dirent<string> option>Asynchronously read the next directory entry via readdir(3) as an fs.Dirent.
A promise is returned that will be fulfilled with an fs.Dirent, or null if there are no more directory entries to read.
Directory entries returned by this function are in no particular order as provided by the operating system's underlying directory mechanisms. Entries added or removed while iterating over the directory might not be included in the iteration results.
@since v12.12.0
Returns. containing {fs.Dirent|null}
abstract member readSync () : Dirent<string> option
abstract member readSync () : Dirent<string> optionSynchronously read the next directory entry as an fs.Dirent. See the POSIX readdir(3) documentation for more detail.
If there are no more directory entries to read, null will be returned.
Directory entries returned by this function are in no particular order as provided by the operating system's underlying directory mechanisms. Entries added or removed while iterating over the directory might not be included in the iteration results.
@since v12.12.0