Functions

f
isErrno(
value: unknown,
...codes: string[]
): value is ErrnoError

Whether value is an Error carrying one of the given Node code strings — ENOENT, EADDRINUSE, EBUSY. With no codes it matches any error that has a string code at all (which includes Node's ERR_* internal errors, e.g. ERR_MODULE_NOT_FOUND).

f
rescue<T, F extends Any, A extends readonly unknown[]>(
fn: (...args: A) => T,
classify: (cause: unknown) => F,
...args: A
): Rescued<T, F>

Calls fn(...args) and returns the value bare, classifying any throw into the declared Failure classify builds — the boundary and the declaration fused into one expression, producing the bare union directly. The sync sibling of Task#mapErr: like that adapter edge it deliberately catches everything, because this IS the edge where a foreign throw becomes a declared failure — chain the original under cause. When the boundary should stay raw and the declaration should be a separate visible rethrow line, use Result.try instead.

f
tryCatch<T, A extends readonly unknown[]>(
fn: (...args: A) => T,
...args: A
): Tried<T>

Calls fn(...args) and reflects the outcome into a Caught box — Result.try, shaped like Promise.try. See the module doc for the flat-classification pattern this is half of.

Interfaces

I
ErrnoError

Minimal shape of a Node system error, declared locally so this module stays runtime-free.

Type Aliases

T
Caught<T, E = unknown> = Ok<T> | Err<E>

What the boundary hands back: the value, or whatever was caught — unknown, honestly, because a catch binding is exactly as untrustworthy.

T
Ok<T> = { readonly ok: true; readonly value: T; readonly error?: undefined; }

The success variant of a caught outcome. error is present-but-undefined for shape stability.

T
Rescued<T, F> = 0 extends 1 & T ? unknown : [T] extends [PromiseLike<unknown>] ? Promise<Awaited<T> | F> : T | F

The outcome of rescue(): the bare T | F union, promise-wrapped when fn was async. A leaking any collapses to unknown so it cannot pose as an inspected type.