Merge pull request #3 from MozillaSecurity/es6

Merge branch 'es6' into master
This commit is contained in:
pyoor 2018-08-23 09:57:10 -04:00 committed by GitHub
commit 8a978de0d8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

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