{ } qjs-modules

fs

Source: lib/fs.js (pure JS) — has a default export object bundling the API

A Node-fs-style filesystem module with synchronous, promise, and stream APIs, built on QuickJS std/os.

Standard streams & helpers

stdin, stdout, stderr (constants). Buffer helpers: buffer(length), bufferFrom(chunk, offset, length), bufferSize(buf), bufferArgument(arg), bufferArguments(arg, offset, length), stringOrBufferArguments(arg, …), bufferToString(buf, offset, length), throwIfNull(error, fn, …).

Classes

ClassDescription
Statsstat-result object (isFile(), isDirectory(), size, times, mode, …).
FileHandleOpen-file handle with read/write/close methods.
inotify_eventArrayBuffer subclass decoding an inotify event.

Synchronous API

FunctionArgsDescription
openSync(filename, flags='r', mode=0o644)1–3Opens a file → fd.
fopenSync(filename, flags, mode) / fdopenSync(fd, flags)1–3Open as a FILE.
closeSync(fd)1Closes an fd.
readSync(fd, buffer, offset, length)4Reads into a buffer.
writeSync(fd, buffer, offset, length)4Writes from a buffer.
readFileSync(file, options)1–2Reads a whole file.
writeFileSync(file, data, options)2–3Writes a whole file.
readdirSync(path)1Lists a directory.
statSync / lstatSync(path)1File status.
existsSync(path)1Existence test.
mkdirSync(path, mode)1–2Creates a directory.
renameSync(old, new)2Renames.
unlinkSync(path)1Removes a file.
copyFileSync(src, dest, flags)2–3Copies.
linkSync / symlinkSync2Creates links.
readlinkSync / realpathSync(path)1Resolves links.
accessSync(pathname, mode)2Accessibility check.
seek(fd, offset, whence) / tell(file)1–3File-position control.
sizeSync(file) / nameSync(file) / fileno(file)1File metadata.
getcwd() / chdir(path) / isatty(file)0–1Process/file helpers.
tmpfileSync() / mkstempSync(template) / tempnamSync(dir, pfx)0–2Temp files.
flushSync(f) / pipe()0–1Flush / create a pipe.
puts(fd, str) / gets(fd)1–2Line write / read.

Async / promise API

open, close, read, write, readFile, copyFile, exists, stat, lstat, mkdir, link, symlink, tmpfile, readAll, readFully — promise variants of the corresponding sync calls.

Streaming readers

FunctionArgsDescription
reader(input, bufferOrBufSize=1024)1–2Async chunk reader.
readerSync(input, bufferOrBufSize=1024)1–2Generator of chunks.
readAllSync(input, bufSize)1–2Reads everything (sync).
readFullySync(input, buf, start, n) / readFully(...)2–4Fills a buffer fully.
createReadStream(path, options)1–2Node-style readable stream.
createWriteStream(path, options)1–2Node-style writable stream.

Event helpers

onRead(file, handler), waitRead(file), onWrite(file, handler), waitWrite(file), watch(filename, options, callback).

Constants

constants (object) plus individual FD_CLOEXEC, F_* (fcntl), and O_* (open) flag exports.