safety-number-one
Version:
Utility functions to work with Promises, functions and async functions safely by converting throws to Result Tuple types
11 lines • 570 B
TypeScript
import type { ResultTuple } from "nice-types";
/**
* Utility function run a synchronous function safely to prevent it from
* throwing and returns a `ResultTuple`.
*
* ### Alternatively
* 1. Run an async function with global util `runAsyncFnSafely`.
* 1. Await a Promise with global util `awaitPromiseSafely`.
*/
export declare function runFnSafely<T extends (...args: any) => any, FnArgs extends Parameters<T>, SuccessfulReturnType extends ReturnType<T>>(fn: T, ...args: FnArgs): ResultTuple<SuccessfulReturnType, Error>;
//# sourceMappingURL=runFnSafely.d.ts.map