Try to fix utils.script.runner again
This commit is contained in:
parent
3b5be216ca
commit
d721eb5b58
1 changed files with 5 additions and 6 deletions
|
@ -86,7 +86,7 @@ class script extends utils {
|
||||||
/**
|
/**
|
||||||
* Wrap command(s) in setInterval, setTimeout, loop or run directly
|
* Wrap command(s) in setInterval, setTimeout, loop or run directly
|
||||||
* @param {string|string[]} cmds - Command(s) to be executed
|
* @param {string|string[]} cmds - Command(s) to be executed
|
||||||
* @returns {string}
|
* @returns {array}
|
||||||
*/
|
*/
|
||||||
static runner (cmds) {
|
static runner (cmds) {
|
||||||
cmds = (Array.isArray(cmds)) ? cmds : [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
|
// Wrap each command in try/catch for use in setInterval, setTimeout, repeater
|
||||||
switch (random.number(50)) {
|
switch (random.number(50)) {
|
||||||
case 0:
|
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:
|
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:
|
case 2:
|
||||||
let n = random.number(random.number(30))
|
return [`for (let i = 0; i < ${random.number(random.number(30))}; i++) { ${script.safely(cmds)} }`]
|
||||||
return script.safely(`for (let i = 0; i < ${n}; i++) { ${script.safely(cmds)} }`)
|
|
||||||
default:
|
default:
|
||||||
return script.safely(cmds)
|
return cmds
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue