The function to call
Optional
argArray: any[]An array of the arguments to pass to the function
The return value of the function or undefined if an exception is thrown
0.10.5
let result = safe((value: string) => {
return JSON.parse(value);
}, ["{ invalid: json value"]);
// result.e instanceof SyntaxError
let result2 = safe((value: string) => {
return JSON.parse(value);
}, ["{ valid: json value"]);
// result2.v === { valid: "json value" }
Call the specified function with zero or more individual arguments, the call will be wrapped in a try / catch block and the result returned wrapped in an ISafeReturn instance. If the function call throws an exception the error property will contain the exception otherwise the value property will contain the value returned from the function.