UNPKG

@piyawasin/attempt

Version:

Inspired by Golang error handling, this package will help you code defensively by always handling the errors.

8 lines (7 loc) 367 B
/** * Executes an async function and returns a tuple [result, error]. * @param func Async function to execute * @param args Arguments to pass to the function */ import type { AttemptResult } from "./types"; export declare function attemptAsync<T, Args extends any[], E = unknown>(func: (...args: Args) => Promise<T>, ...args: Args): Promise<AttemptResult<T, E>>;