Let safely() support Arrays

This commit is contained in:
Christoph Diehl 2018-04-06 19:45:19 +02:00
parent f394b75f38
commit 297002fec4
No known key found for this signature in database
GPG key ID: 799CE5B68FEF404A

View file

@ -68,8 +68,12 @@ class script extends utils {
return JSON.stringify(o)
}
static safely (s) {
return `try { ${s} } catch(e) { }`
static safely (obj) {
if (Array.isArray(obj)) {
return obj.map(s => utils.script.safely(s)).join(' ')
} else {
return `try { ${obj} } catch(e) { }`
}
}
static makeLoop (s, max) {