mirror of
https://github.com/Oreolek/raconteur.git
synced 2024-05-17 00:08:16 +03:00
Now you can do randomly() with a single array argument
This commit is contained in:
parent
f8f0d60916
commit
b3a127be31
11
lib/oneOf.js
11
lib/oneOf.js
|
@ -136,8 +136,13 @@ var oneOf = function (...ary) {
|
||||||
last;
|
last;
|
||||||
|
|
||||||
if (ary.length<2) {
|
if (ary.length<2) {
|
||||||
throw new Error(
|
if (Array.isArray(ary[0]) && ary[0].length > 2) {
|
||||||
"attempted to make randomly() iterator with a 1-length array");
|
ary = ary[0]
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw new Error(
|
||||||
|
"attempted to make randomly() iterator with a 1-length array");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return stringish(function () {
|
return stringish(function () {
|
||||||
var i, offset;
|
var i, offset;
|
||||||
|
@ -179,4 +184,4 @@ var oneOf = function (...ary) {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = oneOf;
|
module.exports = oneOf;
|
||||||
|
|
Loading…
Reference in a new issue