Try to fix utils.script.runner again

This commit is contained in:
pyoor 2018-08-27 19:39:19 -04:00
parent 3b5be216ca
commit d721eb5b58

View file

@ -86,7 +86,7 @@ class script extends utils {
/**
* Wrap command(s) in setInterval, setTimeout, loop or run directly
* @param {string|string[]} cmds - Command(s) to be executed
* @returns {string}
* @returns {array}
*/
static runner (cmds) {
cmds = (Array.isArray(cmds)) ? cmds : [cmds]
@ -95,14 +95,13 @@ class script extends utils {
// Wrap each command in try/catch for use in setInterval, setTimeout, repeater
switch (random.number(50)) {
case 0:
return script.safely(`setInterval(function () { ${script.safely(cmds)} }, ${random.range(100, 400)} )`)
return [`setInterval(function () { ${script.safely(cmds)} }, ${random.range(100, 400)} )`]
case 1:
return script.safely(`setTimeout(function () { ${script.safely(cmds)} }, ${random.range(100, 400)} )`)
return [`setTimeout(function () { ${script.safely(cmds)} }, ${random.range(100, 400)} )`]
case 2:
let n = random.number(random.number(30))
return script.safely(`for (let i = 0; i < ${n}; i++) { ${script.safely(cmds)} }`)
return [`for (let i = 0; i < ${random.number(random.number(30))}; i++) { ${script.safely(cmds)} }`]
default:
return script.safely(cmds)
return cmds
}
}
}