Add support for wrapping arrays elements in try/catch
This commit is contained in:
parent
4d60a6a3c8
commit
9807668e3e
1 changed files with 6 additions and 2 deletions
|
@ -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 + '}'
|
||||
|
|
Loading…
Reference in a new issue