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)
|
return JSON.stringify(o)
|
||||||
},
|
},
|
||||||
safely: function (s) {
|
safely: function (obj) {
|
||||||
return 'try { ' + s + ' } catch(e) { }'
|
if (Array.isArray(obj)) {
|
||||||
|
return obj.map(s => utils.script.safely(s)).join(' ')
|
||||||
|
} else {
|
||||||
|
return `try { ${obj} } catch(e) { }`
|
||||||
|
}
|
||||||
},
|
},
|
||||||
makeLoop: function (s, max) {
|
makeLoop: function (s, max) {
|
||||||
return 'for (let i = 0; i < ' + (max || make.number.range()) + '; i++) {' + s + '}'
|
return 'for (let i = 0; i < ' + (max || make.number.range()) + '; i++) {' + s + '}'
|
||||||
|
|
Loading…
Reference in a new issue