Skip to content

wrapSafe

wrapSafe<TArgs, TResult>(fn): (…args) => TResult | undefined

Wraps a function so that any error it throws yields undefined instead of propagating.

TArgs extends unknown[]

Parameters of the wrapped function.

TResult

Return type of the wrapped function.

(…args) => TResult

The function to wrap.

A function with the same parameters that returns fn’s result, or undefined when fn throws.

(…args) => TResult | undefined