Skip to content

otplib API Documentation / @otplib/totp / wrapResult

Function: wrapResult()

wrapResult<T, Args>(fn): (...args) => OTPResult<T, OTPError>

Defined in: core/src/utils.ts:825

Internal

Wrap a synchronous function to return OTPResult instead of throwing

Preserves the original OTPError subclass so users can access specific error information via instanceof checks.

Type Parameters

T

T

Args

Args extends unknown[]

Parameters

fn

(...args) => T

Returns

(...args): OTPResult<T, OTPError>

Parameters

args

...Args

Returns

OTPResult<T, OTPError>

Released under the MIT License.