Wraps fn in a try...catch and returns the result of fn(x), or returns the fallback if fn(x) throws an error.
fn
try...catch
fn(x)
Rest
throwable(JSON.parse)('fallback')('["Good","JSON"]')// => ['Good', 'JSON']throwable(JSON.parse)('fallback')('[Bad, JSON]')// => 'fallback' Copy
throwable(JSON.parse)('fallback')('["Good","JSON"]')// => ['Good', 'JSON']throwable(JSON.parse)('fallback')('[Bad, JSON]')// => 'fallback'
Generated using TypeDoc
Wraps
fn
in atry...catch
and returns the result offn(x)
, or returns the fallback iffn(x)
throws an error.