UNPKG

return-style

Version:

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

11 lines (10 loc) 216 B
export function getFailure<E = Error>( fn: () => unknown ): [failed: true, error: E] | [faled: false, error: undefined] { try { fn() return [false, void 0] } catch (e: any) { return [true, e] } }