{ } qjs-modules

directory

Source: quickjs-directory.c — module export: Directory (plus static constants)

Iterates directory entries (a wrapper over opendir/readdir). The object is itself an iterator.

Constructor

new Directory([path])   // length 1

Methods

MethodArgsDescription
open(path)1Opens path for reading.
adopt(fd)1Wraps an already-open directory handle.
close()0Closes the directory.
valueOf()0Returns the underlying handle/descriptor.
next()0Returns the next entry (iterator protocol).
return()0Ends iteration.
throw(exception)1Injects an exception into the iteration.
[Symbol.iterator]()0Returns the directory iterator.

Static constants

Entry-shape flags: NAME, TYPE, BOTH — control whether next() yields the name, the type, or both.

Entry types: TYPE_BLK, TYPE_CHR, TYPE_DIR, TYPE_FIFO, TYPE_LNK, TYPE_REG, TYPE_SOCK, TYPE_MASK.