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) 331 B
/** * Executes a function and returns a tuple [result, error]. * @param func Function to execute * @param args Arguments to pass to the function */ import type { AttemptResult } from "./types"; export declare function attempt<T, Args extends any[], E = unknown>(func: (...args: Args) => T, ...args: Args): AttemptResult<T, E>;