Utils / Full Stack / tryit
Function: tryit()
ts
function tryit<Args, Return>(func): (...args) => Return extends Promise<any> ? Promise<[Error, undefined] | [undefined, Awaited<Return>]> : [Error, undefined] | [undefined, Return];A helper to try an async function without forking the control flow. Returns an error first callback like array response as [Error, result]
Type Parameters
| Type Parameter |
|---|
|
|
Parameters
| Parameter | Type |
|---|---|
| (... |
Returns
(...args) => Return extends Promise<any> ? Promise<[Error, undefined] | [undefined, Awaited<Return>]> : [Error, undefined] | [undefined, Return]