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:
parent
f8f0d60916
commit
b3a127be31
11
lib/oneOf.js
11
lib/oneOf.js
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue