fs.ts

view source

Declarations
#

7 declarations

fs_classify_error
#

fs.ts view source

(error: unknown): FsError import {fs_classify_error} from '@fuzdev/fuz_util/fs.js';

Classifies a thrown filesystem error into a discriminated FsError.

Reads the Node code property (ENOENT/EACCES/EPERM/EEXIST) — Deno surfaces the same codes when throwing from node:fs/promises. Unknown codes fall through to io_error.

error

type unknown

returns

FsError

fs_empty_dir
#

fs.ts view source

(dir: string, should_remove?: ((name: string) => boolean) | undefined, options?: RmOptions | undefined): Promise<void> import {fs_empty_dir} from '@fuzdev/fuz_util/fs.js';

Empties a directory, recursively by default. If should_remove is provided, only entries where it returns true are removed.

dir

type string

should_remove?

type ((name: string) => boolean) | undefined
optional

options?

type RmOptions | undefined
optional

returns

Promise<void>

fs_exists
#

fs.ts view source

(path: string): Promise<boolean> import {fs_exists} from '@fuzdev/fuz_util/fs.js';

Checks if a file or directory exists.

path

type string

returns

Promise<boolean>

fs_search
#

FsError
#

fs.ts view source

FsError import type {FsError} from '@fuzdev/fuz_util/fs.js';

Discriminated filesystem error kinds.

The shared error shape for Result<{value: T}, FsError>-returning filesystem deps across the ecosystem. Callers branch on kind instead of regex-matching message. The set is deliberately small — add kinds only when a caller needs to distinguish them.

FsJsonError
#

fs.ts view source

FsJsonError import type {FsJsonError} from '@fuzdev/fuz_util/fs.js';

Extends FsError with invalid_json for read_json-style ops where the file exists but parse fails. Callers can distinguish missing from corrupt (e.g. self-healing config loads) without regex-matching message.

FsSearchOptions
#

fs.ts view source

FsSearchOptions import type {FsSearchOptions} from '@fuzdev/fuz_util/fs.js';

filter?

One or more filter functions, any of which can short-circuit the search by returning false.

type PathFilter | Array<PathFilter>

file_filter?

One or more file filter functions. Every filter must pass for a file to be included.

type FileFilter | Array<FileFilter>

sort?

Pass null or false to speed things up at the cost of volatile ordering.

type boolean | null | ((a: ResolvedPath, b: ResolvedPath) => number)

include_directories?

Set to true to include directories. Defaults to false.

type boolean

cwd?

Sets the cwd for dir unless it's an absolute path or null.

type string | null

Depends on
#

Imported by
#