try-or-value
v1.1.0
Published
a simple utility function for inline try-catch-statements
Downloads
56
Readme
try-or-value
A simple utility function for inline try-catch-statements.
API
tryOrValue(fn, fallbackValueOrFunction)
usage
const myObject = tryOrValue(() => JSON.parse(buggyJSONString), {});
//or
const myObject2 = tryOrValue(() => JSON.parse(buggyJSONString), () => 3);