Fix some uses of random.index instead of random.item
This commit is contained in:
parent
bdeabbbbd4
commit
91f0cbf6c4
1 changed files with 4 additions and 4 deletions
|
@ -37,7 +37,7 @@ var random = {
|
||||||
item: function (list) {
|
item: function (list) {
|
||||||
if (!(list instanceof Array || (typeof list != "string" && "length" in list))) {
|
if (!(list instanceof Array || (typeof list != "string" && "length" in list))) {
|
||||||
Utils.traceback();
|
Utils.traceback();
|
||||||
throw new TypeError("random.index() received a non array type: '" + list + "'");
|
throw new TypeError("random.item() received a non array type: '" + list + "'");
|
||||||
}
|
}
|
||||||
return list[this.number(list.length)];
|
return list[this.number(list.length)];
|
||||||
},
|
},
|
||||||
|
@ -46,17 +46,17 @@ var random = {
|
||||||
for (let i in obj) {
|
for (let i in obj) {
|
||||||
list.push(i);
|
list.push(i);
|
||||||
}
|
}
|
||||||
return this.index(list);
|
return this.item(list);
|
||||||
},
|
},
|
||||||
bool: function () {
|
bool: function () {
|
||||||
return this.index([true, false]);
|
return this.item([true, false]);
|
||||||
},
|
},
|
||||||
pick: function (obj) {
|
pick: function (obj) {
|
||||||
if (typeof obj == "function") {
|
if (typeof obj == "function") {
|
||||||
return obj();
|
return obj();
|
||||||
}
|
}
|
||||||
if (obj instanceof Array) {
|
if (obj instanceof Array) {
|
||||||
return this.pick(this.index(obj));
|
return this.pick(this.item(obj));
|
||||||
}
|
}
|
||||||
return obj;
|
return obj;
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue