UNPKG

return-style

Version:

Non-intrusively convert the result of any function or promise to the user's desired style.

10 lines (8 loc) 208 B
import { Awaitable } from '@blackglory/prelude' export async function getResultAsync<T>(fn: () => Awaitable<T>): Promise<T | undefined> { try { return await fn() } catch { return undefined } }