From b3a127be3166df077d20a9edaeb2d26a869304d9 Mon Sep 17 00:00:00 2001 From: Oreolek Date: Tue, 1 Dec 2015 17:30:59 +0700 Subject: [PATCH] Now you can do randomly() with a single array argument --- lib/oneOf.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/oneOf.js b/lib/oneOf.js index 4129ee6..f940330 100644 --- a/lib/oneOf.js +++ b/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; \ No newline at end of file +module.exports = oneOf;