return fn() or default value (in case of exception)
npm install tryortryor will give you back the return value ofjavascript
var config = tryor(function() {
return JSON.parse(String(fs.readFileSync("config.json")));
}, {}); // instead of
var config = {};
try {
config = JSON.parse(String(fs.readFileSync("config.json")));
} catch (e) {
}
`Works extra well with ES6-style
const variables.Installation
$3
Install using npm npm install tryor
`javascript
var tryor = require("tryor");
`$3
Clone the repo and include it in a script tag git clone https://github.com/olov/tryor.git
`html
``