From b55264b24f1ac9434d91be7fc9e6daac60f6d569 Mon Sep 17 00:00:00 2001 From: Christoph Diehl Date: Tue, 2 May 2017 17:01:32 +0300 Subject: [PATCH] Use let instead of var in script.js --- lib/utils/script.js | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/utils/script.js b/lib/utils/script.js index 8cfb69b..f2554ba 100644 --- a/lib/utils/script.js +++ b/lib/utils/script.js @@ -7,9 +7,9 @@ utils.script = { if (isNaN(numOptional)) { numOptional = 0 } - var arity = list.length - random.number(numOptional) - var params = [] - for (var i = 0; i < arity; i++) { + let arity = list.length - random.number(numOptional) + let params = [] + for (let i = 0; i < arity; i++) { params.push(random.pick([list[i]])) } return '(' + params.join(', ') + ')' @@ -18,8 +18,8 @@ utils.script = { if (!utils.common.getKeysFromHash(methodHash).length || !objectName) { return '' } - var methodName = random.key(methodHash) - var methodArgs = methodHash[methodName] + let methodName = random.key(methodHash) + let methodArgs = methodHash[methodName] if (typeof (methodArgs) === 'function') { // Todo: Hmmmm.. return methodArgs() } @@ -29,9 +29,9 @@ utils.script = { if (!utils.common.getKeysFromHash(attributeHash).length || !objectName) { return '' } - var attributeName = random.key(attributeHash) - var attributeValue = random.pick(attributeHash[attributeName]) - var operator = ' = ' + let attributeName = random.key(attributeHash) + let attributeValue = random.pick(attributeHash[attributeName]) + let operator = ' = ' /* if (typeof(attributeValue) == "number" && Random.chance(8)) { operator = " " + Make.randomAssignmentOperator() + " "; @@ -43,17 +43,17 @@ utils.script = { return objectName + '.' + attributeName + operator + attributeValue + ';' }, makeConstraint: function (keys, values) { - var o = {} - var n = random.range(0, keys.length) + let o = {} + let n = random.range(0, keys.length) while (n--) { o[random.pick(keys)] = random.pick(values) } return o }, makeRandomOptions: function (baseObject) { - var o = {} - var unique = random.some(Object.keys(baseObject)) - for (var i = 0; i < unique.length; i++) { + let o = {} + let unique = random.some(Object.keys(baseObject)) + for (let i = 0; i < unique.length; i++) { o[unique[i]] = random.pick(baseObject[unique[i]]) } return JSON.stringify(o) @@ -65,7 +65,7 @@ utils.script = { return 'try { ' + s + ' } catch(e) { }' }, makeLoop: function (s, max) { - return 'for (var i = 0; i < ' + (max || make.number.rangeNumber()) + '; i++) {' + s + '}' + return 'for (let i = 0; i < ' + (max || make.number.rangeNumber()) + '; i++) {' + s + '}' }, makeArray: function (type, arrayLength, cb) { if (type === null || type === undefined) { @@ -73,7 +73,7 @@ utils.script = { } switch (random.number(8)) { case 0: - var src = 'function() { var buffer = new ' + type + 'Array(' + arrayLength + ');' + let src = 'function() { let buffer = new ' + type + 'Array(' + arrayLength + ');' src += utils.script.makeLoop('buffer[i] = ' + cb() + ';', arrayLength) src += 'return buffer;}()' return src