Closed stefaanMLB closed 1 year ago
I can see from the source code that you intended for tryit
to work both for sync and async calls, but this isn't working correctly i.m.h.o., consider this code:
async function boot() {
const fn = tryit((x: string) => x)
const result = fn('test')
console.log(isPromise(result))
console.log(result)
console.log(await result)
}
boot()
The result is
true
Promise { <pending> }
[ undefined, 'test' ]
ideally the return value is not a Promise when a sync function is passed.
Sorry, works fine in v11
Can you add a sync version of
tryit
? Something like thisIt would also be usefull to have to option to convert errors not of Error type into Error objects in
tryit
like I did in the example