diff --git a/lib/utils/script.js b/lib/utils/script.js index e73730f..5a9ff80 100644 --- a/lib/utils/script.js +++ b/lib/utils/script.js @@ -87,13 +87,14 @@ class script extends utils { return `${random.number()} % ${o.pick(objName)}.length` } + /** + * Wrap command(s) in setInterval, setTimeout, loop or run directly + * @param {string|string[]} cmds - Command(s) to be executed + * @returns {string} + */ static runner (cmds) { - /** - * Wrap command(s) in setInterval, setTimeout, loop or run directly - * @param {Object|String} cmds - Command(s) to be executed - */ cmds = (Array.isArray(cmds)) ? cmds : [cmds] - cmds = cmds.filter(function (i) { return i !== undefined }) + cmds = cmds.filter((i) => i !== undefined) if (cmds.length) { if (random.chance(50)) { // Wrap each command in try/catch for use in setInterval, setTimeout, repeater @@ -106,9 +107,9 @@ class script extends utils { let n = random.number(random.number(30)) return `for (let i = 0; i < ${n}; i++) { ${utils.script.safely(cmds)} }` } - } else { - return cmds } + + return utils.script.safely(cmds) } }