Streaming file-system utilities for the anabranch ecosystem.
File already exists when it should not.
Structured error types for file-system operations.
File content is invalid (e.g., malformed JSON).
Path is a directory when a file was expected.
Path is not a directory when a directory was expected.
Permission denied accessing the file system.
Unknown file system error.
Copies a single file from src to dst.
Creates a directory and any missing parents, like mkdir -p.
Checks whether a path exists.
Finds all entries under root whose relative path matches the glob pattern.
Lists the immediate children of a directory.
Reads an entire file as a Uint8Array.
Reads a JSON file and parses it, returning the value typed as T.
Streams lines from a text file one at a time using node:readline.
Reads an entire file as a UTF-8 string.
Removes a file or directory recursively. No error if the path doesn't exist.
Returns metadata for a path without reading its contents.
Recursively walks a directory tree, yielding each entry.
Watches path for file-system changes, yielding a FsEvent for each.
Writes a Uint8Array to a file, creating or overwriting it.
Serialises value as JSON and writes it to a file, creating or overwriting it.
Writes a UTF-8 string to a file, creating or overwriting it.
An entry in a directory listing.
-
isDirectory: boolean
Whether the entry is a directory.
-
isFile: boolean
Whether the entry is a regular file.
-
isSymlink: boolean
Whether the entry is a symbolic link.
-
name: string
The entry's file name (not the full path).
A file-system change event, as yielded by watch.
-
kind: "create" | "modify" | "remove"
The type of change.
-
paths: string[]
Absolute paths of the affected files.
Options for glob. Same as WalkOptions without match.
File metadata returned by stat.
-
atime: Date
Last access time.
-
birthtime: Date
Creation time.
-
isDirectory: boolean
Whether the path is a directory.
-
isFile: boolean
Whether the path is a regular file.
-
isSymlink: boolean
Whether the path is a symbolic link.
-
mtime: Date
Last modification time.
-
size: number
Size in bytes.
A directory entry with its full path, as yielded by walk and glob.
-
path: string
The absolute path to the entry.
Options for walk.
-
includeDirs: boolean
Whether to include directories in results.
-
includeFiles: boolean
Whether to include regular files in results.
-
includeSymlinks: boolean
Whether to include symbolic links in results.
-
match: RegExp[]
Only yield entries whose path (relative to root) matches at least one pattern. When omitted all entries are included.
-
maxDepth: number
Maximum recursion depth.
0means only immediate children of root. -
skip: RegExp[]
Skip entries whose path (relative to root) matches any of these patterns.
Errors that can occur when copying a file.
Errors that can occur when reading directories.
Errors that can occur when ensuring a directory.
Errors that can occur when checking existence.
Errors that can occur when reading files.
| PermissionDenied
| ReadError
| InstanceType<InvalidData>
| Unknown
Errors that can occur when reading JSON files.
Errors that can occur when removing a path.
Errors that can occur when stat-ing a path.
Errors that can occur when watching the file system.
| IsDirectory
| PermissionDenied
| WriteError
| Unknown
Errors that can occur when writing files.