diff --git a/make/arrays.js b/make/arrays.js index 6dfa967..cce03f8 100644 --- a/make/arrays.js +++ b/make/arrays.js @@ -1,7 +1,7 @@ make.arrays = { filledArray: function (fn, limit) { let array = []; - let size = limit || random.number(make.tinyNumber); + let size = limit || random.number(make.numbers.tinyNumber); for (let i = 0; i < size; i++) { array.push(fn()); diff --git a/make/colors.js b/make/colors.js index 2f23005..554e866 100644 --- a/make/colors.js +++ b/make/colors.js @@ -1,9 +1,9 @@ make.colors = { colors: function() { return random.pick([ - make.colorRGB, - make.colorHSL, - make.colorKeywords + make.colors.colorRGB, + make.colors.colorHSL, + make.colors.colorKeywords ]); }, diff --git a/make/files.js b/make/files.js index ba723f1..a68be9e 100644 --- a/make/files.js +++ b/make/files.js @@ -33,9 +33,9 @@ make.files = { }, file: function () { return random.pick([ - make.image, - make.video, - make.audio + make.files.image, + make.files.video, + make.files.audio ]); }, }; diff --git a/make/fonts.js b/make/fonts.js index 3610047..e6365ad 100644 --- a/make/fonts.js +++ b/make/fonts.js @@ -15,35 +15,35 @@ make.fonts = { return ["serif", "sans-serif", "cursive", "fantasy", "monospace"]; }, fontFamilies: function() { - return ['"' + "Times New Roman" + '"', "Arial", "Courier", "Helvetica"]; + return ["'Times New Roman'", "Arial", "Courier", "Helvetica"]; }, fontFamily: function () { - let s = random.pick(make.fontFamilies); + let s = random.pick(make.fonts.fontFamilies); if (random.chance(8)) { - s += ", " + random.pick(make.fontFamiliesGeneric); + s += ", " + random.pick(make.fonts.fontFamiliesGeneric); } return s; }, fontSize: function () { - return make.unsignedNumber() + make.lengthUnit(); + return make.numbers.unsignedNumber() + make.fonts.lengthUnit(); }, font: function () { let s = ""; if (random.chance(4)) { - s += random.pick(make.fontStyles) + " "; + s += random.pick(make.fonts.fontStyles) + " "; } if (random.chance(4)) { - s += random.pick(make.fontVariants) + " "; + s += random.pick(make.fonts.fontVariants) + " "; } if (random.chance(4)) { - s += random.pick(make.fontWeights) + " "; + s += random.pick(make.fonts.fontWeights) + " "; } if (random.chance(4)) { - s += make.number() + "/"; + s += make.numbers.number() + "/"; } - s += make.fontSize(); + s += make.fonts.fontSize(); s += " "; - s += Make.fontFamily(); + s += Make.fonts.fontFamily(); return "'" + s + "'"; } }; diff --git a/make/network.js b/make/network.js index e1deb41..192810d 100644 --- a/make/network.js +++ b/make/network.js @@ -38,13 +38,13 @@ make.network = { return ["turn", "turns", "stun", "stuns"] }, randomIPv4: function() { - return random.pick([random.number(255), make.number]) + "." + - random.pick([random.number(255), make.number]) + "." + - random.pick([random.number(255), make.number]) + "." + - random.pick([random.number(255), make.number]); + return random.pick([random.number(255), make.numbers.number]) + "." + + random.pick([random.number(255), make.numbers.number]) + "." + + random.pick([random.number(255), make.numbers.number]) + "." + + random.pick([random.number(255), make.numbers.number]); }, randomIPv6: function() { - return "[" + make.stringFromBlocks([":", function() { return make.digitsHex(random.range(1, 4)) }]) + "]" + return "[" + make.stringFromBlocks([":", function() { return make.strings.digitsHex(random.range(1, 4)) }]) + "]" }, goodHostnames: function() { return [ "0.0.0.0", diff --git a/make/numbers.js b/make/numbers.js index b4af571..17f0a51 100644 --- a/make/numbers.js +++ b/make/numbers.js @@ -19,14 +19,14 @@ make.numbers = { return n; }, rangeNumber: function () { - return random.pick([1, 2, 3, 4, 6, 8, 16, 32, 64, make.tinyNumber]); + return random.pick([1, 2, 3, 4, 6, 8, 16, 32, 64, make.numbers.tinyNumber]); }, tinyNumber: function () { return Math.pow(2, random.number(12)); }, unsignedNumber: function () { if (random.chance(2)) { - return Math.abs(make.number()); + return Math.abs(make.numbers.number()); } return Math.pow(2, random.number(65)) + random.number(3) - 1; }, @@ -35,9 +35,9 @@ make.numbers = { }, number: function () { let value = random.choose([ - [10, make.float], - [10, [make.rangeNumber, make.tinyNumber]], - [ 1, Make.unsignedNumber] + [10, make.numbers.float], + [10, [make.numbers.rangeNumber, make.numbers.tinyNumber]], + [ 1, Make.numbers.unsignedNumber] ]); return random.chance(10) ? -value : value; } diff --git a/make/shaders.js b/make/shaders.js index 885fa79..e0fcf91 100644 --- a/make/shaders.js +++ b/make/shaders.js @@ -135,8 +135,8 @@ make.shaders = { shaderPair: function(v, f) { let i = random.number(v.length); return { - vertex: Utils.quote(v[i].join("\n")), - fragment: Utils.quote(f[i].join("\n")) + vertex: utils.common.quote(v[i].join("\n")), + fragment: utils.common.quote(f[i].join("\n")) }; }, }; diff --git a/make/strings.js b/make/strings.js index 2e1ad76..6004d69 100644 --- a/make/strings.js +++ b/make/strings.js @@ -6,18 +6,18 @@ make.strings = { let s = ""; if (maxlen == null || maxlen === undefined) { - maxlen = make.rangeNumber(); + maxlen = make.numbers.rangeNumber(); } for (let i = 0; i < maxlen; i++) { - //s += String.fromCodePoint(Random.pick(Make.layoutCharCodes)); + //s += String.fromCodePoint(Random.pick(make.fonts.layoutCharCodes)); s += "A" } return s; }, quotedString: function (maxlen) { - return utils.quote(make.string(maxlen)); + return utils.common.quote(make.strings.string(maxlen)); }, stringFromBlocks: function (set, maxlen) { let s = ""; diff --git a/make/units.js b/make/units.js index 46b1eb3..400f75f 100644 --- a/make/units.js +++ b/make/units.js @@ -5,9 +5,9 @@ make.units = { ]); }, length: function () { - return make.number() + make.lengthUnit(); + return make.numbers.number() + make.units.lengthUnit(); }, percent: function () { - return make.number() + "%"; + return make.numbers.number() + "%"; }, }; diff --git a/utils/block.js b/utils/block.js index 9b5cbc1..69ffe40 100644 --- a/utils/block.js +++ b/utils/block.js @@ -17,8 +17,8 @@ utils.block = { return item; } if (item instanceof(Array)) { - var s = ""; - for (var i = 0; i < item.length; i++) { + let s = ""; + for (let i = 0; i < item.length; i++) { s += go_deeper(item[i]); } return s; @@ -26,8 +26,8 @@ utils.block = { return item; } - var asString = ""; - for (var i = 0; i < list.length; i++) { + let asString = ""; + for (let i = 0; i < list.length; i++) { asString += go_deeper(list[i]); } diff --git a/utils/common.js b/utils/common.js index a793328..af11e2c 100644 --- a/utils/common.js +++ b/utils/common.js @@ -16,7 +16,7 @@ utils.common = { }, getKeysFromHash: function (obj) { let list = []; - for (var p in obj) { + for (let p in obj) { list.push(p); } return list; @@ -50,7 +50,7 @@ utils.common = { for (let p in obj2) { try { if (obj2[p].constructor == Object) { - obj1[p] = Utils.mergeHash(obj1[p], obj2[p]); + obj1[p] = utils.common.mergeHash(obj1[p], obj2[p]); } else { obj1[p] = obj2[p]; } diff --git a/utils/script.js b/utils/script.js index 3d3dcd2..64c810a 100644 --- a/utils/script.js +++ b/utils/script.js @@ -3,30 +3,30 @@ utils.script = { if (isNaN(numOptional)) { numOptional = 0; } - var arity = list.length - Random.number(numOptional); + var arity = list.length - random.number(numOptional); var params = []; for (var i = 0; i < arity; i++) { - params.push(Random.pick([list[i]])); + params.push(random.pick([list[i]])); } return "(" + params.join(", ") + ")"; }, methodCall: function (objectName, methodHash) { - if(!Utils.getKeysFromHash(methodHash).length || !objectName) { + if(!utils.common.getKeysFromHash(methodHash).length || !objectName) { return ""; } - var methodName = Random.key(methodHash); + var methodName = random.key(methodHash); var methodArgs = methodHash[methodName]; if (typeof(methodArgs) == "function") { // Todo: Hmmmm.. return methodArgs(); } - return objectName + "." + methodName + JS.methodHead(methodArgs); + return objectName + "." + methodName + utils.script..methodHead(methodArgs); }, setAttribute: function (objectName, attributeHash) { - if(!Utils.getKeysFromHash(attributeHash).length || !objectName) { + if(!utils.common.getKeysFromHash(attributeHash).length || !objectName) { return ""; } - var attributeName = Random.key(attributeHash); - var attributeValue = Random.pick(attributeHash[attributeName]); + var attributeName = random.key(attributeHash); + var attributeValue = random.pick(attributeHash[attributeName]); var operator = " = "; /* if (typeof(attributeValue) == "number" && Random.chance(8)) { @@ -40,16 +40,16 @@ utils.script = { }, makeConstraint: function (keys, values) { var o = {}; - var n = Random.range(0, keys.length); + var n = random.range(0, keys.length); while (n--) { - o[Random.pick(keys)] = Random.pick(values); + o[random.pick(keys)] = random.pick(values); } return o; }, makeRandomOptions: function (base_o) { - var o = {}, unique = Random.some(Object.keys(base_o)); + var o = {}, unique = random.some(Object.keys(base_o)); for (var i = 0; i < unique.length; i++) { - o[unique[i]] = Random.pick(base_o[unique[i]]); + o[unique[i]] = random.pick(base_o[unique[i]]); } return JSON.stringify(o); }, @@ -60,40 +60,40 @@ utils.script = { return "try { " + s + " } catch(e) { }"; }, makeLoop: function (s, max) { - return "for (var i = 0; i < " + (max || Make.rangeNumber()) + "; i++) {" + s + "}"; + return "for (var i = 0; i < " + (max || make.numbers.rangeNumber()) + "; i++) {" + s + "}"; }, makeArray: function (type, arrayLength, cb) { if (type == null || type === undefined) { - type = Random.index(["Uint8", "Float32"]); + type = random.index(["Uint8", "Float32"]); } - switch (Random.number(8)) { + switch (random.number(8)) { case 0: var src = "function() { var buffer = new " + type + "Array(" + arrayLength + ");"; - src += JS.makeLoop("buffer[i] = " + cb() + ";", arrayLength); + src += utils.script.makeLoop("buffer[i] = " + cb() + ";", arrayLength); src += "return buffer;}()"; return src; case 1: - return "new " + type + "Array([" + Make.filledArray(cb, arrayLength) + "])"; + return "new " + type + "Array([" + make.arrays.filledArray(cb, arrayLength) + "])"; default: return "new " + type + "Array(" + arrayLength + ")"; } }, randListIndex: function (objName) { - return Random.number() + ' % ' + o.pick(objName) + '.length'; + return random.number() + ' % ' + o.pick(objName) + '.length'; }, addElementToBody: function (name) { - return "(document.body || document.documentElement).appendChild" + JS.methodHead([name]); + return "(document.body || document.documentElement).appendChild" + utils.script..methodHead([name]); }, forceGC: function () { - if (Platform.isMozilla) {} - if (Platform.isChrome) { + if (platform.isMozilla) {} + if (platform.isChrome) { if (window.GCController) return GCController.collect(); } - if (Platform.isSafari) {} - if (Platform.isIE) {} + if (platform.isSafari) {} + if (platform.isIE) {} }, getRandomElement: function() { - return "document.getElementsByTagName('*')[" + Random.number(document.getElementsByTagName("*").length) + "]"; + return "document.getElementsByTagName('*')[" + random.number(document.getElementsByTagName("*").length) + "]"; } };