@paykit-sdk/core
Version:
The Payment Toolkit for Typescript
8 lines (6 loc) • 332 B
TypeScript
type Success<T> = [T, undefined];
type Failure<E = Error> = [undefined, E];
type Result<T, E = Error> = Success<T> | Failure<E>;
declare function tryCatchAsync<T, E = Error>(promise: Promise<T>): Promise<Result<T, E>>;
declare function tryCatchSync<T, E = Error>(fn: () => T): Result<T, E>;
export { tryCatchAsync, tryCatchSync };