1
0
Fork 0
mirror of https://github.com/Oreolek/raconteur.git synced 2024-05-02 00:49:20 +03:00

Now you can do randomly() with a single array argument

This commit is contained in:
Alexander Yakovlev 2015-12-01 17:30:59 +07:00
parent f8f0d60916
commit b3a127be31

View file

@ -136,8 +136,13 @@ var oneOf = function (...ary) {
last;
if (ary.length<2) {
throw new Error(
"attempted to make randomly() iterator with a 1-length array");
if (Array.isArray(ary[0]) && ary[0].length > 2) {
ary = ary[0]
}
else {
throw new Error(
"attempted to make randomly() iterator with a 1-length array");
}
}
return stringish(function () {
var i, offset;
@ -179,4 +184,4 @@ var oneOf = function (...ary) {
};
};
module.exports = oneOf;
module.exports = oneOf;