Add support for wrapping arrays elements in try/catch

This commit is contained in:
pyoor 2018-03-28 13:26:28 -04:00
parent 4d60a6a3c8
commit 9807668e3e

View file

@ -58,8 +58,12 @@ utils.script = {
}
return JSON.stringify(o)
},
safely: function (s) {
return 'try { ' + s + ' } catch(e) { }'
safely: function (obj) {
if (Array.isArray(obj)) {
return obj.map(s => utils.script.safely(s)).join(' ')
} else {
return `try { ${obj} } catch(e) { }`
}
},
makeLoop: function (s, max) {
return 'for (let i = 0; i < ' + (max || make.number.range()) + '; i++) {' + s + '}'