Skip to content

otplib API Documentation / otplib / wrapResultAsync

Function: wrapResultAsync()

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

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

Internal

Wrap an async 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) => Promise<T>

Returns

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

Parameters

args

...Args

Returns

Promise<OTPResult<T, OTPError>>

Released under the MIT License.